Tuesday, October 29, 2013

Deploy rails application in apache2 server using passenger

Summary:
-------
In ubuntu create virtual server and deploy rails application using passenger and apache server

Step 1:
-------
Make sure apache is installed and it work on ubuntu properly. Check it in browser.

http://localhost

It should display  "It Works!"


Step 2:
-------
Install passenger gem on ubuntu

$ gem install passenger


Step 3:
-------
Install passenger apache module.

$ sudo passenger-install-apache2-module


Step 4:
-------
We need to install require module for apache passenger

Step 5:
-------
After installation we need to add the passenger ruby modules at apache config file.

$ sudo subl /etc/apache2/apache2.conf

At last you need to add this lines

LoadModule passenger_module /home/kannan/.rvm/gems/ruby-1.9.3-p374/gems/passenger-4.0.21/buildout/apache2/mod_passenger.so
PassengerRoot /home/kannan/.rvm/gems/ruby-1.9.3-p374/gems/passenger-4.0.21
PassengerDefaultRuby /home/kannan/.rvm/wrappers/ruby-1.9.3-p374/ruby

Step 6:
-------
Create default sites enabled file and pase this code

$ sudo touch /etc/apache2/sites-enabled/railsproject.local

Suppose you have a Rails application in /somewhere. Add a virtual host to your
Apache configuration file and set its DocumentRoot to /somewhere/public:

eg. somewhere-> /var/www/railsproject


  #railsproject.local

   NameVirtualHost *:80
   <VirtualHost *:80>
      ServerName www.railsproject.local
      # !!! Be sure to point DocumentRoot to 'public'!
      DocumentRoot /somewhere/public   
      <Directory /somewhere/public>
         # This relaxes Apache security settings.
         AllowOverride all
         # MultiViews must be turned off.
         Options -MultiViews
      </Directory>
   </VirtualHost>

Step 7:
-------
Open hosts file and add the local ip of your application

$ subl /etc/hosts

Add last you need to add

127.0.0.1    railsproject.local


Step 8:
-------
Restart your apache2 server

$ sudo service apache2 restart


Step 9:
-------
check your virtula hosted project domain

www.railsproject.local


Rocks!!!!

3 comments: