By Swaroop SM

You have built an awesome application using Ruby on Rails, and have no idea how to make it available to the world wide web. By the end of this tutorial, you will have your application up and running on Apache. We will be using passenger with Apache in this post. So, let's get started.

1. Install Dependecies:

Run $ bundle install to install all the gems specified in the Gemfile.

2. Database Production Settings & Migrations:

Assuming you are in the root directory of your project, open your config/database.yml and edit the username/password in the production section of the file. Once done run the following commands in sequence:

    $ bundle exec rake db:create RAILS_ENV=production
    $ bundle exec rake db:migrate RAILS_ENV=production


3. Preparing your application

Navigate to your config/environments/production.rb and set the following:

    config.serve_static_assets = true
    config.assets.compile = true


Run the to compile all your stylesheets and javascripts

    $ bundle exec rake assets:precompile


4. Install Passenger

This is the gem that does all the magic of deploying our rails application.

    $ gem install passenger


5. Configure Apache for serving the App

Run the following command:

    $ passenger-install-apache2-module


  • If there are any dependencies that Apache needs, it prompts and you can install it via your package manager.(then again run: passenger-install-apache2-module).

  • Once that is done, the installation will ask you to copy paste some lines into the apache configuration file.

  • Restart Apache.

6. Setup Virtual Config for Apache

In your sites-available directory of Apache, create a file called, my_app and paste the following lines:

    <VirtualHost *:80>
        ServerName YOURSERVERNAME
        DocumentRoot /PROJECT_PATH/public
        <Directory /PROJECT_PATH/public>
            Options -MultiViews
            AllowOverride All
            Order deny,allow
            Allow from all


7. Enable your site

$ sudo a2ensite my_app

Restart Apache, navigate to your server name and enjoy :)

comments powered by Disqus