Deploying Ruby on Rails Application

If you are using Rails version 2.3.4 then Check the New Rails Application deployment process. For earlier version please continue following the steps given below. Remember to freeze your application with the Rails version, as the server is using the latest version of Rail.

To deploy your newly build rails application on the Nirvaat.com hosting account, first freeze all the gems and plug-ins that you used. It would be better if you could freeze the rails gem also, as it will make the site immune to rails upgrade on the web server and would always use application’s local copy.

Now follow below given steps to make your application working on the hosting server:

1. Using FTP software of your choice, upload the complete application on the web server.

2. Open a SSH session and go at the root of your personal directory (place where you can see the directory public_html).

3. Create symbolic link to map your app name on the public folder of your application

ln -s /home/username/path_to_your_app/public public_html/your_app_name

4. We have to add following lines in the .htaccess file, if they are not already there. It will tell Apache to follow the symbolic link that we just created.

vi public_html/.htaccess

Add these lines:

Options +FollowSymLinks +ExecCGI

RewriteEngine On

5. Now in order to make the files executable we need to modify the permissions of the application scripts,
chmod -R 755 your_app/*
6. Edit your .htaccess file in the /public/ directory with the last Rewrite rule pointing to dispatch.fcgi
RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]
7. Edit your public/dispatch.fcgi file and replace the first line like this:
replace #!/usr/bin/ruby18 with #!/usr/bin/ruby
8. It is the path of Ruby executable on the web server. Restart your FCGI Processes using the following command at the shell prompt,
pkill -9 -u username -f dispatch.fcgi
9. At this stage you may want to test the installation by visiting the address:
http://www.your_domain.com/your_app_name/
You should obtain the congratulations page of Ruby on Rails, this means that your application has started working as required.
10. Once you’re done testing this, you need to create a simple route to display a page as the index page (like an index.html or index.php page) First rename the index.html to index.html.hid in the public directory unless you want to use it. OR you can delete index.html.
rm your_app/public/index.html
Then
vi your_app/config/routes.rb
On top of all the routes, add:
map.connect ”, :controller => ‘your_controller’, :action => ‘action_to_be_seen_as_index’
11. Finally, edit the environment.rb file to put the app into production mode:
vi your_app/config/environment.rb
add the following line before the RAILS_ENV declaration, like this:
ENV['RAILS_ENV'] = “production”
RAILS_ENV = ENV['RAILS_ENV']

Now, you should be all right and ready to show your work to the rest of the world! You will be able to access the index page by typing:

http://www.your_domain.com/your_app_name/

Random Testimonial

  • ~ Elance ID – catchlight

    Elance ID – catchlight"This was a seemingly small job, but a very important one and one that needed to be done right. A certain level of knoowledge is required for this type of task and nirvaat carried it out beautyifully. Nice work and I'd reccommend this provider to anyone working with"

  • Read more testimonials »

Posting tweet...