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?
LVL 12
lexxwernAsked:
Who is Participating?
 
nizsmoConnect With a Mentor DeveloperCommented:
Step by step tutorial below...
Source: http://wiki.rubyonrails.org/rails/pages/Tutorial
              http://wiki.rubyonrails.org/rails/pages/GettingStartedWithRails



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
      HowToSetTheBaseURLsOfYourRailsApps.
   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
   </Directory>
</VirtualHost>

Also, make sure that apache has write permissions to the /path/application/tmp directory.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.