199
4. Ruby on Rails
Ruby on Rails is an open source web framework for developing database backed web applications. It is optimized for sustainable productivity of the programmer since it lets the programmer to write code
by favouring convention over configuration.
4.1. Installation
Before installing Rails you should install Apache and MySQL. To install the Apache package, please refer to Section 1, “HTTPD - Apache2 Web Server” [p. 187]. For instructions on installing MySQL
refer to Section 1, “MySQL” [p. 206]. Once you have Apache and MySQL packages installed, you are ready to install Ruby on Rails
package. To install the Ruby base packages and Ruby on Rails, you can enter the following command in the
terminal prompt:
sudo apt-get install rails
4.2. Configuration
Modify the
etcapache2sites-availabledefault
configuration file to setup your domains. The first thing to change is the DocumentRoot directive:
DocumentRoot pathtorailsapplicationpublic
Next, change the Directory pathtorailsapplicationpublic directive:
Directory pathtorailsapplicationpublic Options Indexes FollowSymLinks MultiViews ExecCGI
AllowOverride All Order allow,deny
allow from all AddHandler cgi-script .cgi
Directory
You should also enable the mod_rewrite module for Apache. To enable mod_rewrite module, please enter the following command in a terminal prompt:
sudo a2enmod rewrite
Finally you will need to change the ownership of the
pathtorailsapplicationpublic
and
pathtorailsapplicationtmp
directories to the user used to run the Apache process:
200
sudo chown -R www-data:www-data pathtorailsapplicationpublic sudo chown -R www-data:www-data pathtorailsapplicationtmp
Thats it Now you have your Server ready for your Ruby on Rails applications.
4.3. References
• See the Ruby on Rails
17
website for more information. • Also Agile Development with Rails
18
is a great resource. • Another place for more information is the Ruby on Rails Ubuntu Wiki
19
page.
17 http:rubyonrails.org 18 http:pragprog.comtitlesrails3agile-web-development-with-rails-third-edition
19 https:help.ubuntu.comcommunityRubyOnRails
201
5. Apache Tomcat