Debian Sarge (3.1) with Ruby on Rails and Apache 2 with FastCGI - Page 4

Install Apache and Ruby

apt-get install apache2 apache2-doc
apt-get install libapache2-mod-php4 libapache2-mod-perl2 php4 php4-cli php4-common php4-curl php4-dev php4-domxml php4-gd php4-imap php4-ldap php4-mcal php4-mhash php4-mysql php4-odbc php4-pear php4-xslt curl libwww-perl imagemagick
apt-get install ruby ruby1.8-dev rdoc apache2-prefork-dev make

Edit /etc/apache2/apache2.conf.

joe /etc/apache2/apache2.conf


DirectoryIndex index.html index.cgi index.php index.xhtml


DirectoryIndex index.html index.htm index.shtml index.cgi index.php index.php3 index.xhtml

Edit /etc/mime.types and comment out the following lines:

joe /etc/mime.types

#application/x-httpd-php                        phtml pht php
#application/x-httpd-php-source phps
#application/x-httpd-php3 php3
#application/x-httpd-php3-preprocessed php3p
#application/x-httpd-php4 php4

Edit /etc/apache2/mods-enabled/php4.conf and comment out the following lines:

joe /etc/apache2/mods-enabled/php4.conf

<IfModule mod_php4.c>
# AddType application/x-httpd-php .php .phtml .php3
# AddType application/x-httpd-php-source .phps

Edit /etc/apache2/ports.conf and add Listen 443:

joe /etc/apache2/ports.conf

Listen 80
Listen 443

Now we have to enable some Apache modules (SSL, rewrite and suexec):

a2enmod ssl
a2enmod rewrite
a2enmod suexec

Install the FastCGI library

*Note 2.4.0 is the current version if it is not available visit to get the latest.

cd /usr/local/src
tar xvzf fcgi-2.4.0.tar.gz
cd fcgi-2.4.0
./configure && make && make install

Installation of for Apache2

Download the mod_fastcgi sources from If the Link is not working, try to get the latest mod_fastcgi sources instead. Make the mod_fastcgi module.

cd /usr/local/src
tar xvzf mod_fastcgi-2.4.2.tar.gz
cd mod_fastcgi-2.4.2
cp Makefile.AP2 Makefile
make top_dir=/usr/share/apache2
make install top_dir=/usr/share/apache2

Enable mod_fastcgi in Apache2

echo 'LoadModule fastcgi_module /usr/lib/apache2/modules/' > /etc/apache2/mods-available/fastcgi.load
a2enmod fastcgi

Installation of ruby-fcgi bindings, Ruby GEM and Rails:

Download the ruby-fcgi bindings from If the Link is not working, try to get the latest ruby-fcgi bindings instead.

cd /usr/local/src
tar xvzf ruby-fcgi-0.8.6.tar.gz
cd ruby-fcgi-0.8.6
ruby install.rb config
ruby install.rb setup
ruby install.rb install
cd /usr/local/src
tar zxvf rubygems-0.8.11.tgz
cd rubygems-0.8.11
ruby1.8 setup.rb
gem install rubygems-update
gem install rails --include-dependencies
gem install mysql

Answer 2 mysql 2.7(ruby)

Restart Apache:

/etc/init.d/apache2 restart

Share this page:

6 Comment(s)

Add comment


From: Ka1N at: 2006-10-27 06:40:55

/bin/hostname -f /etc/hostname

 should be

/bin/hostname -F /etc/hostname

... with a capital F

From: Anonymous at: 2006-05-15 18:27:52

I find that many rails problems revolve around permissions and setting fcgi/cgi


chmod -R 755 public
chmod -R 755 log

# triple check your .htaccess file that .fcgi is selected
# replace this line
RewriteRule ^(.*)$ dispatch.cgi [QSA,L]
# with
RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]
# make sure you've used the ispconfig control panel to make a database for this site
# fill out the database name, username, and password in your database.yml
# ~/config/database.yml
#example configuration

adapter: mysql
database: web1_db1
username: web1_u1
password: <yourpassword>

# make sure you set the path to ruby in files ~/public/dispatch.fcgi and dispatch.cgi
# use the command which ruby to identify the correct path
root@ubuntu:/# which ruby
#if this is your path then the first line of your dispatch files would look like this


From: Anonymous at: 2006-05-30 21:51:59

Tim, just working through your how-to and found that I get an error on the following command:

root@vps:/etc/postfix/ssl# mv -f smtpd.key.unencrypted smtpd.key openssl req -new -x509 -extensions v3_ca -keyout cakey.pem -out cacert.pem -days 3650
mv: invalid option -- n
Try `mv --help' for more information.

From: tomw at: 2006-06-08 15:24:25

Thats because there was an error in the formatting. It should have been two lines thus:

mv -f smtpd.key.unencrypted smtpd.key

openssl req -new -x509 -extensions v3_ca -keyout cakey.pem -out cacert.pem -days 3650

Fixed it sorry.

From: Anonymous at: 2006-06-27 03:36:04

From: at: 2007-04-07 03:04:26

ISPConfig's default directory is now /var/www, No need to use expert mode or change it.