Using Ruby On Rails With Apache2 On Debian Etch

Version 1.0
Author: Falko Timme

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 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, but on other addresses as well (e.g., you should set a root password for these addresses as well:

mysqladmin -h -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


to become the root user again.

Share this page:

Suggested articles

6 Comment(s)

Add comment



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 -

By: gerard

The point of the article was to show how to get RoR on apache2, not on mongrel, which is an entirely different HTTP server.

By: evden eve nakliyat

Good work! Your post/article is an excellent example of why I keep comming back to read your excellent quality content that is forever updated. Thank you!


see rails wiki post:

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

By: Douglas

Pretty good for the apache2 part even though this is old. I 'm running

debian squeeze now. All except for the rails part. I use rvm and do not install any ruby as a root user. An article on how to use this with rvm would be nice. Keep in mind that there is also passenger and passenger gem now.

Thanks! Good job.


By: mc0e

This recipe looks like it'll create a rails app directory where all the code and templates are owned by the www-data user, which is poor practice from a security standpoint. 

gazmcghee raises concerns about the ruby version.  However, the link they point to is now lacking content.  In general, I've been concerned by the lack of secure download sources (ie cryptographically signed) for ruby other than those that come from the operating system vendors.  There's a lot of situations where you might ignore the issue, but I would have thought the ruby community would have matured enough by now to provide such things for those who do need it.