系统中的80端口已经因为使用lampp被占用,故不能再次使用nginx来做解析:
deploy/staging
server "yan.com", user: "root", roles: %w{app db web}, my_property: :my_value
set :branch, ‘master‘
set :rails_env, ‘production‘
set :deploy_to, "/opt/lampp/htdocs/#{ fetch(:application) }"
set :puma_state, "#{shared_path}/tmp/pids/puma.state"
set :puma_pid, "#{shared_path}/tmp/pids/puma.pid"
set :puma_bind, "tcp://0.0.0.0:9951"
set :puma_conf, "#{shared_path}/puma.rb"
set :puma_access_log, "#{shared_path}/log/puma_error.log"
set :puma_error_log, "#{shared_path}/log/puma_access.log"
set :puma_role, :app
set :puma_env, fetch(:rack_env, fetch(:rails_env, ‘production‘))
set :puma_threads, [0, 16]
set :puma_workers, 0
set :puma_init_active_record, false
set :puma_preload_app, true
deploy.rb
# config valid for current version and patch releases of Capistrano
lock "~> 3.10.1"
set :application, "dsadas"
set :repo_url, "git@gitee.co"
set :puma_role, :app
set :puma_init_active_record, true
set :puma_config_file, ‘config/puma.rb‘
# set :bundle_gemfile, "china_enterprise/Gemfile"
# Default branch is :master
# ask :branch, `git rev-parse --abbrev-ref HEAD`.chomp
# Default deploy_to directory is /var/www/my_app_name
# set :deploy_to, ‘/var/www/my_app_name‘
# Default value for :scm is :git
# set :scm, :git
# Default value for :format is :airbrussh.
# set :format, :airbrussh
# You can configure the Airbrussh format using :format_options.
# These are the defaults.
# set :format_options, command_output: true, log_file: ‘log/capistrano.log‘, color: :auto, truncate: :auto
# Default value for :pty is false
# set :pty, true
# Default value for :linked_files is []
# append :linked_files, ‘config/database.yml‘, ‘config/secrets.yml‘
set :linked_files, fetch(:linked_files, []).push(
‘config/database.yml‘, ‘config/secrets.yml‘, ‘config/wechat.yml‘)
# Default value for linked_dirs is []
# append :linked_dirs, ‘log‘, ‘tmp/pids‘, ‘tmp/cache‘, ‘tmp/sockets‘, ‘public/system‘
set :linked_dirs, fetch(:linked_dirs, []).push(
‘log‘, ‘tmp/pids‘, ‘tmp/cache‘, ‘tmp/sockets‘, ‘public/assets‘, ‘public/uploads‘)
# set :sidekiq_config, ‘config/sidekiq.yml‘
# Default value for default_env is {}
# set :default_env, { path: "/opt/ruby/bin:$PATH" }
# Default value for keep_releases is 5
# set :keep_releases, 5
namespace :deploy do
desc ‘Restart application‘
task :restart do
on roles(:app), in: :sequence, wait: 5 do
end
end
after :restart, :‘puma:restart‘ #添加此项重启puma
after :publishing, :restart
after :restart, :clear_cache do
on roles(:web), in: :groups, limit: 3, wait: 10 do
end
end
end
capful
# Load DSL and set up stages
require "capistrano/setup"
# Include default deployment tasks
require "capistrano/deploy"
# Load the SCM plugin appropriate to your project:
#
# require "capistrano/scm/hg"
# install_plugin Capistrano::SCM::Hg
# or
# require "capistrano/scm/svn"
# install_plugin Capistrano::SCM::Svn
# or
require "capistrano/scm/git"
install_plugin Capistrano::SCM::Git
# Include tasks from other gems included in your Gemfile
#
# For documentation on these, see for example:
#
#
require "capistrano/rvm"
# require "capistrano/rbenv"
# require "capistrano/chruby"
require "capistrano/bundler"
require "capistrano/rails/assets"
require ‘capistrano/puma‘
install_plugin Capistrano::Puma, load_hooks: false
require "capistrano/rails/migrations"
# require "capistrano/passenger"
# Load custom tasks from `lib/capistrano/tasks` if you have any defined
Dir.glob("lib/capistrano/tasks/*.rake").each { |r| import r }
主要问题在于使用Apache做解析:
<VirtualHost *:80>
ServerName crisp-code.com
DocumentRoot /var/www/crisp-code.com/current/public
# Redirect all requests that don‘t match a file on disk under DocumentRoot get proxied to Puma
RewriteEngine On
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
RewriteRule ^/(.*)$ http://127.0.0.1:9951%{REQUEST_URI} [P]
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/crisp-code.com.access.log combined
ErrorLog ${APACHE_LOG_DIR}/crisp-code.com.error.log
# Don‘t allow client to fool Puma into thinking connection is secure
RequestHeader unset X-Forwarded-Proto
# Anything under public is open to the world
<Directory /var/www/crisp-code.com/current/public>
Satisfy any
Allow from all
Require all granted
Options -MultiViews
</Directory>
# Set Expiration date for all assets to one year in the future
<Location ^/assets/.*$>
# Use of ETag is discouraged when Last-Modified is present
Header unset ETag
FileETag None
# RFC says only cache for 1 year
ExpiresActive On
ExpiresDefault "access plus 1 year"
</Location>
# Compress HTML on the fly
AddOutputFilterByType DEFLATE text/html
</VirtualHost>
<VirtualHost *:80>
ServerAlias www.crisp-code.com
Redirect 301 / http://crisp-code.com
</VirtualHost>