rails,  rvm,  nginx,  ubuntu,  passenger,  ror

Installing Nginx with Phusion Passenger, RVM, and Ruby on Rails on Ubuntu

Digital Ocean has a great tutorial on how to install Nginx with Phusion Passenger, RVM, and RoR on Ubuntu.

Installing Nginx with Phusion Passenger, RVM, and Ruby on Rails on Ubuntu

Digital Ocean has a great tutorial on how to install Nginx with Phusion Passenger, RVM, and RoR on Ubuntu.

We recently had to do exactly that and created an updated guide.

Update Ubuntu packages:

  • sudo apt-get update

If this is a clean install it can also be a good idea to install all the security updates:

  • sudo apt-get upgrade
  • sudo apt-get autoclean

A tip: if we plan to use mysql2 gem libmysqlclient-dev is a requirement:

  • sudo apt-get install libmysqlclient-dev

Install and start RVM (we might need to download and install GPG signature, gpg —keyserver hkp://keys.gnupg.net —recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3):

  • curl -L get.rvm.io | bash -s stable
  • source ~/.rvm/scripts/rvm

Check to see if any required libraries are missing:

  • rvm requirements

If anything is missing install it with rvmsudo and run rvm requirements to make sure all is good.

Install ruby 2.2.1 and start using it:

  • rvm install 2.2.1
  • rvm use 2.2.1 —default

Install rails and passenger gems.

  • gem install rails
  • gem install passenger

Passenger install scripts will let us know if anything is missing and will install Nginx and all the required components:

  • rvmsudo passenger-install-nginx-module
  • sudo apt-get install nodejs

To be able to use nginx as a service:

  • sudo service nginx start

We first need to install startup scripts:

Now we can point the configuration file (assuming the default location) to point to our rails project on the file-system.

  • sudo nano /opt/nginx/conf/nginx.conf

server { listen 80; server_name example.com; passenger_enabled on; root /var/www/my_app/current/public; }

Subscribe to The infinite monkey theorem

Get the latest posts delivered right to your inbox