Search code examples
ruby-on-railsnginxvirtualhostpassengerruby-on-rails-2

running multiple rails websites using phusion passenger 3.0.17 with nginx


I searched google for deploying multiple rails websites using phusion passenger 3.0.17 with nginx but I didn't get relevant results. Any how I completed passenger nginx setup by running passenger-install-nginx-module command.

Ques 1) I am looking for proper beginner tutorial for running multiple rails websites using phusion passenger 3.0.17 with nginx

Ques 2) I am looking commands for start, stop, restart the (whole passenger nginx server (ie) for all websites) and also for (Individual rails websites)

Note: I am not looking for passenger standalone solution. I am using REE 1.8.7 and rails 2.3.14


Solution

  • According to the documentation for Passenger, you create a new vhost for each app you want to deploy. And point the site root at your apps public directory, and add the passenger_enabled directive. Exactly the same as deploying with Apache.

    http {
        ...
    
        server {
            listen 80;
            server_name www.mycook.com;
            root /webapps/mycook/public;
            passenger_enabled on;
        }
    
        ...
    }
    

    More here: http://www.modrails.com/documentation/Users%20guide%20Nginx.html#deploying_a_ror_app

    In regards question 2. Restarting depends on what you are trying to do. I'm going to assume you're using a distro that uses init.d

    These are 3 cases where you do a different kind of 'restart'.

    You have an issue with some config you have on Nginx. Or it's behaving strangely. So you would restart the Nginx service like this: /etc/init.d/nginx restart

    The next case is you have a rails or sinatra app deployed on Nginx with the passenger module. And you want to make it reload some changes you just pushed to the server. Passenger watches the tmp/restart.txt file in your application. So by simply runnging touch tmp/restart.txt. While cd'd into the app's folder will tell Passenger to reload the application.

    And the last case for restarting/reloading is reload for Nginx. You use this when you add or change your VHOSTs. /etc/init.d/nginx reload. This allows you to reload your vhosts and other config without dropping connections.

    Have a gander at the Passenger Documentation, it is very thorough. nginx-passenger docs