I've been trying for more than a day now to make Nginx and Passenger work for my Rails app, but all I ever get is: The Nginx welcome page. Why?
I have installed Nginx in the default location /opt/nginx
, like so:
# Install passenger gem
$ gem install passenger
# Install dependencies for Nginx/Passenger
$ apt-get install libcurl4-openssl-dev
# Compile it
$ passenger-install-nginx-module
And the (I think) relevant parts of the file /opt/nginx/conf/nginx.conf
look like this:
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;
}
...
And when I check the "root location" (public), I can see that the app is there (it was deployed with Capistrano):
$ ls /home/deploy/current/public
404.html 422.html 500.html assets css favicon.ico js robots.txt system
...or 1 level up:
$ 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
And looking at the Rails production.log, I can see that it never went beyond compiling assets:
$ 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)
And looking at the Nginx error.log, I can't see anything wrong (normal visits to the URL ("home page") don't seem to create any entries):
$ tail -f /opt/nginx/logs/error.log
And looking at the Nginx access.log, I can't see anything wrong (normal visits to the URL ("home page") don't seem to create any entries):
$ 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!
Also:
- I'm sure Nginx is running (since I see the welcome page)
- I'm sure the nginx.conf file is being taken into account by Nginx (i.e. if I uncomment
#access_log logs/access.log main;
without uncommenting the#log_format main
, it complains) - I'm on: Rails 3.2.16 / ruby 2.0.0p353 / Ubuntu 13.10
What could be wrong here?