Deploying rails app using apache and passenger on ubuntu

Hey all

If you want to use apache to deploy your rails app than passenger has made your task really easy.

I assume that you have already installed apache if not do it using

sudo apt-get install apache2

Now follow these steps below and get going.

First step it to install passenger gem using

sudo gem install passenger

Once done the next step is to install the apache2 module for passenger using

sudo passenger-install-apache2-module.

I will prompt you with an option. Select #1

When you do this it will start compiling the files and will prompt for errors if any. Like when I did it for the first time I was asked to installed a couple of missing lib files required to configure along passenger. Example

apt-get install lib-curl4-openssl-dev

apt-get install apache2-prefork-dev

apt-get install libapr1-dev

apt-get install libaprutil1-dev

If every thing is installed file it will ask you to add few lines to your httpd.conf file.

LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-3.0.13/ext/apache2/mod_passenger.so
PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-3.0.13
PassengerRuby /usr/bin/ruby1.8

Once thats done. You will again need to add few more likes to your httpd.conf file which is actually setting up DocumentRoot for you app. will looks something like


ServerName www.yourhost.com
# !!! Be sure to point DocumentRoot to ‘public’!
DocumentRoot /somewhere/public

# This relaxes Apache security settings.
AllowOverride all
# MultiViews must be turned off.
Options -MultiViews

Make sure you replace the DocumentRoot with a valid path.

So the final conf file will look like this

LoadModule passenger_module /usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.13/ext/apache2/mod_passenger.so
PassengerRoot /usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.13
PassengerRuby /usr/local/bin/ruby


ServerName www.domain.com
# !!! Be sure to point DocumentRoot to ‘public’!
DocumentRoot /var/www/app/public

# This relaxes Apache security settings.
AllowOverride all
# MultiViews must be turned off.
Options -MultiViews

Once done close your file and restart apache using

/etc/init.d/apache2 restart

go you your url and check if it works. If not let me know I shall guide you but I think there should not be any issues.

Isn’t that really simple? Yes it is. Njoy Rails.

Be Sociable, Share!

Leave a Reply

Your email address will not be published. Required fields are marked *