• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 7684
  • Last Modified:

Configuring Apache For Ruby On Rails

I have an installation of LAMP through XAMPP; i.e. I have PHP, MySql, Apache configured.
I also downloaded Ruby and installed Rails through Ruby Gems command line.

What do I do next? How do I create a Rails app and how to configure Apache to render the same?
1 Solution
Step by step tutorial below...
Source: http://wiki.rubyonrails.org/rails/pages/Tutorial

Apache needs to be configured for running CGI files in order for Rails to run. So make sure you have AddHandler cgi-script .cgi somewhere in your Apache config file.

   1. Set up Apache for the Rails application. If you plan to run your application at the DocumentRoot of a virtual host (perhaps as your entire web site), see Example for Apache conf below. If you would like it to live elsewhere see
   2. Go to rails/ (or whatever is your ServerName) and check that you get the Congratulations, youre on Rails! screen
   3. Follow the guidelines on the Congratulations, youre on Rails! screen

Example for Apache conf

In the Apache configuration given, replace the /path/application with the full path to the rails directory unpacked with the tar.gz, and be sure to append the public or log directory on where noted below. I also had to turn on CGI and set some access requirements as shown below. The AllowOverride line is important  internally, Rails uses some redirection that takes place in a .htaccess file located in the public folder. (Suse 9.1s Apache is locked down fairly tight.)

Rails also requires the mod_rewrite module.

LoadModule rewrite_module modules/mod_rewrite.so
LoadModule env_module modules/mod_env.so

<VirtualHost *:80>
   SetEnv RAILS_ENV development
   ServerName rails
   DocumentRoot /path/application/public/
   ErrorLog /path/application/log/apache.log

   <Directory /path/application/public/>
      Options ExecCGI FollowSymLinks
      AddHandler cgi-script .cgi
      AllowOverride all
      Order allow,deny
      Allow from all

Also, make sure that apache has write permissions to the /path/application/tmp directory.

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now