我已经尝试了一天多来让Nginx和Passenger为我的Rails应用程序工作,但我得到的只是:Nginx欢迎页面。为什么?
我已经在默认位置安装了Nginx /opt/nginx
,像这样:
# Install passenger gem
$ gem install passenger
# Install dependencies for Nginx/Passenger
$ apt-get install libcurl4-openssl-dev
# Compile it
$ passenger-install-nginx-module
和(我认为)文件的相关部分 /opt/nginx/conf/nginx.conf
看起来像这样:
http {
passenger_root /usr/local/rvm/gems/ruby-2.0.0-p353/gems/passenger-4.0.29;
passenger_ruby /usr/local/rvm/wrappers/ruby-2.0.0-p353/ruby;
server {
listen 80;
server_name www.my-domain.com;
root /home/deploy/current/public;
passenger_enabled on;
location / {
root html;
index index.html index.htm;
passenger_enabled on;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
passenger_enabled on;
}
...
当我检查“根位置”(公共)时,我可以看到应用程序在那里(它与Capistrano一起部署):
$ ls /home/deploy/current/public
404.html 422.html 500.html assets css favicon.ico js robots.txt system
...或1级以上:
$ ls /home/deploy/current
app Capfile config.ru doc Gemfile.lock log public resque.pid script tmp
assets_manifest.yml config db Gemfile lib LOG Rakefile REVISION test vendor
看看Rails production.log,我可以看到它从未超越编译资产:
$ tail -f /home/deploy/current/log/production.log
Compiled page_specific/some_file_5.css (137ms) (pid 28316)
Compiled page_specific/some_file_4.css (19ms) (pid 28316)
Compiled page_specific/some_file_3.css (3ms) (pid 28316)
Compiled page_specific/some_file_2.css (3ms) (pid 28316)
Compiled page_specific/some_file_1.css (16ms) (pid 28316)
Compiled application.css (3131ms) (pid 28316)
看看Nginx error.log,我看不出任何错误(正常访问URL(“主页”)似乎没有创建任何条目):
$ tail -f /opt/nginx/logs/error.log
看看Nginx access.log,我看不出任何错误(正常访问URL(“主页”)似乎没有创建任何条目):
$ tail -f /opt/nginx/logs/error.log
[ 2013-12-29 01:16:55.6792 2099/7fa534fca740 agents/Watchdog/Main.cpp:697 ]: All Phusion Passenger agents started!
也:
- 我确定Nginx正在运行(因为我看到欢迎页面)
- 我确定nginx.conf文件 是 被Nginx考虑在内(即如果我取消注释
#access_log logs/access.log main;
没有取消注释#log_format main
,它抱怨) - 我在:Rails 3.2.16 / ruby 2.0.0p353 / Ubuntu 13.10
这可能有什么问题?