0

我正在尝试在运行带有 Unicorn + Nginx 的 Ubuntu 12.04 的 Vagrant VM 中设置本地 Rails 3.2 开发环境。我安装了带有软链接的 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_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;
}

独角兽 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
4

1 回答 1

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并覆盖它。

于 2013-09-11T19:11:19.303 回答