Search code examples
ruby-on-railsrubyruby-on-rails-4nginxpassenger

Unable to configure passenger and nginx for rails app deployment


I am deploying a rails app on VPS with CentOS. I have installed passenger with gem install passenger. And to install nginx I have used rvmsudo passenger-install-nginx-module.

In the nginx config file i have set:

server { 
        listen       80; 
        server_name  my-ip-address;  

       location / { 
            root   /home/deploy/repos/application-name/public; 
            passenger_enabled on; 
            rails_env production;  
        }
        ...
}

When I execute sudo service nginx status I get following:

nginx (pid 21015 21014) is running...

which shows nginx is running.

But I am getting This webpage is not available on browser.

Even I get the same result when I put on the rails server in the development mode with rails s and try to check in the browser with my-ip-address:3000

Can anyone help with what might be the issue?

When I run the command passenger-config restart-app the result is:

Phusion Passenger is currently not serving any applications

I need a suggestion on whether this is the problem with the nginx or passenger?

One more question is-

If my passenger is not installed correctly but nginx is installed correctly then would I be able to see the "welcome to nginx page"?

Update:

I tried running passenger start -p 3000 -d -e production by which passenger serves in the background. Now if I do passenger-status I get two instances of passenger out of which one says Phusion Passenger is currently not serving any applications and the other one shows like:

Version : 5.0.21
Date    : 2016-01-16 10:42:42 +0530
Instance: feOajf7V (nginx/1.8.0 Phusion_Passenger/5.0.21)

----------- General information -----------
Max pool size : 6
App groups    : 1
Processes     : 1
Requests in top-level queue : 0

----------- Application groups -----------
/home/deploy/repos/application-name/public (production):
  App root: /home/deploy/repos/application-name
  Requests in queue: 0
  * PID: 22003   Sessions: 0       Processed: 0       Uptime: 4m 17s
    CPU: 0%      Memory  : 36M     Last used: 4m 17s ago

And if I run passenger-config restart-app I get result as:

Please select the application to restart.
 ‣   /home/deploy/repos/application-name/public (production)
     Cancel

Does this mean passenger is working correctly? But i see webpage not available in the browser.


Solution

  • I think you haven't run passenger in your project's directory. In the root directory of your project type:

    passenger start -p <port>
    

    where <port> is the port on which you'd like to run your app (ex: 8000).

    UPDATE

    According the updates in your question and the comments below, the problem doesn't seem to reside in the configuration of nginx or passenger. Since you try accessing your server not locally but with the real ip of your VPS, there's a chance that the ports in question aren't open. You can check if so here.