Using Ruby On Rails With Apache2 On Debian Etch

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Submitted by falko (Contact Author) (Forums) on Sun, 2007-05-27 15:59. :: Debian | Apache

Using Ruby On Rails With Apache2 On Debian Etch

Version 1.0
Author: Falko Timme <ft [at] falkotimme [dot] com>
Last edited 05/19/2007

This article shows how you can install Ruby on Rails (RoR) and integrate it in Apache2 on a Debian Etch system (including a short section at the end showing how to use RoR in a web site created with ISPConfig). Ruby on Rails is a web application framework which is rapidly gaining popularity among web programmers. It aims to increase the speed and ease with which database-driven web sites can be created and offers skeleton code frameworks (scaffolding) from the outset. Applications using the RoR framework are developed using the Model-View-Controller design pattern.

This document comes without warranty of any kind! I want to say that this is not the only way of setting up such a system. There are many ways of achieving this goal but this is the way I take. I do not issue any guarantee that this will work for you!

 

1 Preliminary Note

I will use the hostname testapplication.example.com in this tutorial for the virtual host running Ruby on Rails.

 

2 Installing Ruby And Rails

In order to install Ruby and Ruby on Rails, we simply run

apt-get install ruby libzlib-ruby rdoc irb rubygems rails eruby

 

3 Installing Apache2 And mod-fcgid

Ruby on Rails can be integrated in Apache2 using mod-fcgid. Therefore we install the following packages:

apt-get install apache2 libapache2-mod-fcgid libfcgi-ruby1.8

Afterwards, we enable a few Apache modules:

a2enmod ssl
a2enmod rewrite
a2enmod suexec
a2enmod include

and reload Apache:

/etc/init.d/apache2 force-reload

 

4 Installing MySQL And The Ruby MySQL Bindings

Most probably you or your users will like to create database-driven Ruby on Rails applications, therefore we install the MySQL server and the Ruby MySQL bindings now:

apt-get install libmysql-ruby mysql-server

You should set a root password for MySQL now:

mysqladmin -u root password yourrootsqlpassword

If MySQL is listening not only on 127.0.0.1, but on other addresses as well (e.g. server1.example.com), you should set a root password for these addresses as well:

mysqladmin -h server1.example.com -u root password yourrootsqlpassword

 

5 Creating Our Ruby On Rails Environment

We can now create a directory in which we want to develop our future RoR applications. I'd like to develop them in /var/rails, so I create that directory now:

mkdir /var/rails

Apache2 should have read/write access to that directory, so we make the Apache user (www-data on Debian) and Apache group (again www-data) the owner and group of that directory:

chown -R www-data:www-data /var/rails

Now we can create our first RoR application which we will call testapplication. We will create testapplication under the user www-data so that Apache has read/write access to it:

cd /var/rails
su -m www-data

Now that we're logged in as www-data, we run

rails testapplication

This will create a directory called testapplication within /var/rails that contains all directories and files we need to develop our RoR application.

Next, we type in

exit

to become the root user again.


Please do not use the comment function to ask for help! If you need help, please use our forum.
Comments will be published after administrator approval.
Submitted by sadf3f4fw (registered user) on Tue, 2008-01-08 11:41.

see rails wiki post: http://wiki.rubyonrails.org/rails/pages/RailsOnDebian

"Note:
Do not install rails using apt-get! The debian repository includes a very old and broken version."

Submitted by gazmcghee (registered user) on Tue, 2007-11-20 04:45.

This guy seems to be a sys admin, not a Ruby developer. Rubyists almost without exception use mongrel, not fcgi, and this tutorial results in an old version of Ruby (via apt-get). To get Ruby 1.8.6 on Debian you have to compile it - see http://www.urbanpuddle.com/articles/2007/08/17/mongrel-cluster-1-0-2-and-ruby-1-8-5

Submitted by gerard (not registered) on Wed, 2009-09-23 01:58.
The point of the article was to show how to get RoR on apache2, not on mongrel, which is an entirely different HTTP server.
Sponsored Links: Unified Communications: Thoughts, Strategies and Predictions
Join the discussion.
www.seamlessenterprise.com

IP Convergence
Integrate your wireless and wireline networks.
Learn how from the experts at Sprint.
www.seamlessenterprise.com

Wireless & Wireline Integration
Thoughts, strategies and solutions: join the discussion
www.seamlessenterprise.com

Unified Communications 2009
Join the Discussion. Now.
www.seamlessenterprise.com