我正在尝试使用Unicorn + Nginx在运行Ubuntu 12.04的Vagrant VM中设置本地Rails 3.2 dev环境。我使用软链接安装了nginx,如下所示:
sudo apt-get install nginx
Create symlink for nginx conf file for dactarkhoj
cd /etc/nginx/sites-enabled
sudo ln -s /vagrant/config/nginx.conf dactarkhoj.conf
sudo service nginx start
Unicorn也正在设置,我使用
启动它unicorn_rails -c /vagrant/config/unicorn.rb -D
现在由于某种原因,当我打开浏览器时,我只收到“欢迎使用nginx”消息而不是rails应用程序。可能导致这种情况的可能陷阱是什么?
nginx.conf文件是
upstream unicorn {
server unix:/tmp/unicorn.dactarkhoj.sock fail_timeout=0;
}
server {
listen 80 default;
root /vagrant/public;
try_files $uri/index.html $uri @unicorn;
location @unicorn {
proxy_pass http://unicorn;
}
error_page 500 502 503 504 /500.html;
}
Unicorn conf文件是
worker_processes 4
rails_root = File.expand_path('../..', __FILE__)
working_directory rails_root
listen '/tmp/unicorn.dactarkhoj.sock'
pid File.expand_path('tmp/pids/unicorn.pid', ENV['RAILS_ROOT'])
# combine REE with "preload_app true" for memory savings
# http://rubyenterpriseedition.com/faq.html#adapt_apps_for_cow
preload_app true
# Set the path of the log files inside the log folder of the testapp
stderr_path "/vagrant/log/unicorn.stderr.log"
stdout_path "/vagrant/log/unicorn.stdout.log"
before_fork do |server, worker|
defined?(ActiveRecord::Base) and ActiveRecord::Base.connection.disconnect!
old_pid = "#{ server.config[:pid] }.oldbin"
unless old_pid == server.pid
begin
Process.kill :QUIT, File.read(old_pid).to_i
rescue Errno::ENOENT, Errno::ESRCH
end
end
end
after_fork do |server, worker|
defined?(ActiveRecord::Base) and ActiveRecord::Base.establish_connection
end
答案 0 :(得分:1)
正如你所说,这是你的设置:
Create symlink for nginx conf file for dactarkhoj
cd /etc/nginx/sites-enabled
sudo ln -s /vagrant/config/nginx.conf dactarkhoj.conf
sudo service nginx start
我认为您应该将 dactarkhoj.conf 复制到 / etc / nginx / sites-enabled / default 并覆盖它。