Tuesday 26 February 2013

Apache2 + Passenger Installation for rails on Ubuntu

There are some steps to install and configure apache2 & phusion passenger

To install Apache web server and its documentation & utilities on Linux machine using following commands

sudo apt-get install apache2




To Check the installation, Open web browser and type localhost or 127.0.0.1
It will look like this.

If you are using rvm, goto appropriate ruby version using rvm use 1.9.2(i'm having ruby version 1.9.2) and install passenger gem


gem install passenger

To install apache2 module in passenger type

passenger-install-apache2-module



If all depandencies are fullfilled, it will install otherwise it will give list of command you have to install to run passanger.

Snapshot of asking for dependencies. There are following dependencies.






If all dependencies are satisfied you don't have to run following commands

sudo apt-get install apache2-prefork-dev
sudo apt-get install libapr1-dev
sudo apt-get install libaprutil1-dev


After installing dependencies, run passenger-install-apache2-module again.

After that it will compling this module, When module finished its compilation, It shows The Apache 2 module was successfully installed and halt for press Enter

Now you can copy the lines which will show in the terminal(passenger & ruby path and its compilation file)

Paste these lines into /etc/apache2/apache2.conf


After pressing ENTER, the Deploying a Ruby on Rails application: an example heading will shown, As shown in in the snapshot


Copy theses line and paste into /etc/apache2/apache2.conf

For Production Mode

<VirtualHost *:80>
    ServerName 127.0.0.1
    DocumentRoot /somewhere/public
    <Directory /somewhere/public>
        Allow from all
       Options -MultiViews
    </Directory>

</VirtualHost>




For Development Mode

<VirtualHost *:80>
    ServerName 127.0.0.1
    RailsEnv development
    DocumentRoot /somewhere/public
    <Directory /somewhere/public>
        Allow from all
       Options -MultiViews
    </Directory>
</VirtualHost>


DocumentRoot will look like this:- /path to your project directory/public

Run rake assets:precompile in application directory(needed only
in production mode
) and restart apache server by

sudo /etc/init.d/apache2 restart

Hope this will help you ....PLz share your comments....
Enjoy :)

1 comment :