Search code examples
ruby-on-railsnginxdeploymentpassengerproduction-environment

Passenger + NGINX: Phusion Passenger is currently not serving any applications


Phusion Passenger + NGINX in production environment

I have done everything as usual with my ROR-application, but passenger not working with it. Have no idea whats wrong...

sudo passenger-config restart-app

Phusion Passenger is currently not serving any applications.

/etc/nginx/sites-available/myapp

server {
    listen 80;
    server_name _;

    # Tell Nginx and Passenger where your app's 'public' directory is
    root /var/www/myapp/public;
    passenger_app_root /var/www/myapp;
    rails_env production;

    passenger_enabled on;
    passenger_ruby /home/myuserapp/.rvm/gems/ruby-2.3.1/wrappers/ruby;
}

In sites-enabled have a soft symlink myapp to /etc/nginx/sites-available/myapp

sudo passenger-status

Version : 5.1.4
Date    : 2017-05-25 06:56:30 +0300
Instance: byXevAbZ (nginx/1.10.3 Phusion_Passenger/5.1.4)

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

----------- Application groups -----------

But have some passenger instances running...

sudo passenger-config list-instances

Name                       PID      Description
--------------------------------------------------------------------------
byXevAbZ                   1085     nginx/1.10.3 Phusion_Passenger/5.1.4

Solution

  • I ran sudo nginx -t command

    nginx: [warn] conflicting server name "_" on 0.0.0.0:80, ignored
    nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
    nginx: configuration file /etc/nginx/nginx.conf test is successful
    

    First warning cofused me, so i decide the problem is in conflict myapp-site and defult one.

    So i just turn of default site and restart nginx. And everything worked!

    sudo rm /etc/nginx/sites-enabled/default
    sudo service nginx restart
    

    Final config file:

    /etc/nginx/sites-available/myapp

    server {
        listen 80;
        server_name myapp.com;
    
        # Tell Nginx and Passenger where your app's 'public' directory is
        root /var/www/myapp/current/public;
        rails_env production;
    
        # Turn on Passenger
        passenger_enabled on;
        passenger_ruby /home/myuserapp/.rvm/gems/ruby-2.3.1/wrappers/ruby;
    }
    

    P.S. Correct me if you understand the subject deeper.