Last Updated: February 25, 2016
·
1.266K
· alanstirling

Multiple versions of Ruby with Nginx

The following is how to setup nginx on Ubuntu to run additional ruby versions for rails applications.

Select the version of Ruby you want, using your Ruby version manager of choice.

$ -> rvm use 2.0.0-p0
OR
$ -> rbenv use 2.0.0-p0

Run the following command to start a standalone version of passenger using a unix socket. Check your version of Nginx and replace the version number if different.

$ -> passenger start --socket /tmp/[app_name].socket -d --nginx-version 1.0.5 -e production

Here is the Nginx configuration to get it to use the unix socket you have just opened. Remember to use the name of the socket you created in the previous command.

upstream app_upstream {
    server unix:/tmp/[app_name].socket;
}

server {
    listen 80;
    server_name app.me.com;
    root /apps/[app_name]/public;

    location / {
        proxy_pass http://app_upstream;
        proxy_set_header Host $host;
    }
}