ruby-iconRuby on Rails, or simply Rails, is an open source web application framework built on top of the Ruby programming language. In this article, we will show you how to install Ruby, Ruby on Rails and Nginx with Passenger support  on Debian-based distributions (Ubuntu VPS and Debian VPS).



First install Ruby using RVM

curl -L | bash -s stable --ruby

To start using RVM run:

source /usr/local/rvm/scripts/rvm

To verify everything is done correctly, use the command “ruby -v”.
The output should be similar to the following:

# ruby --version
ruby 2.0.0p247 (2013-06-27 revision 41674) [i686-linux]


Install Rails and Passenger

gem install rails passenger


Install Nginx with Passenger.

apt-get install libcurl4-openssl-dev
rvmsudo passenger-install-nginx-module

Select the first option when prompted and press Enter.
(1. This installer will compile and install Nginx with Passenger support.)

If the installation is successful, you will see a message similar to the following:
Nginx with Passenger support was successfully installed.

Create an init script (/etc/init.d/nginx) with the following content:

#! /bin/sh

# Provides:          nginx
# Required-Start:    $all
# Required-Stop:     $all
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: starts the nginx web server
# Description:       starts nginx using start-stop-daemon


test -x $DAEMON || exit 0

set -e

case "$1" in
        echo -n "Starting $DESC: "
        start-stop-daemon --start --quiet --pidfile /opt/nginx/logs/$ \
                --exec $DAEMON -- $DAEMON_OPTS
        echo "$NAME."
        echo -n "Stopping $DESC: "
        start-stop-daemon --stop --quiet --pidfile /opt/nginx/logs/$ \
                --exec $DAEMON
        echo "$NAME."
        echo -n "Restarting $DESC: "
        start-stop-daemon --stop --quiet --pidfile \
                /opt/nginx/logs/$ --exec $DAEMON
        sleep 1
        start-stop-daemon --start --quiet --pidfile \
                /opt/nginx/logs/$ --exec $DAEMON -- $DAEMON_OPTS
        echo "$NAME."
        echo -n "Reloading $DESC configuration: "
        start-stop-daemon --stop --signal HUP --quiet --pidfile /opt/nginx/logs/$ \
                --exec $DAEMON
        echo "$NAME."
        echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
        exit 1

exit 0

To start the Nginx service run:

chmod a+x /etc/init.d/nginx
service nginx start
update-rc.d nginx defaults


Install MySQL/MariaDB and Postgresql Support

apt-get install libmysqld-dev # or libmariadbd-dev
apt-get install libpq-dev
gem install mysql2 pq

Of course you don’t have to do any of this if you use one of our Linux VPS services, in which case you can simply ask our expert linux admins to install this for you. They are available 24×7 and will take care of your request immediately.

PS. If you liked this post please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks