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

by TomW May 04, 2006.

This howto will step you through installing Debian (Sarge) with Ruby on Rails and Apache 2 with FastCGI managed with ISPConfig.

It will use the following software:

  • Web Server: Apache 2.0.x
  • Mail Server: Postfix
  • DNS Server: BIND9
  • FTP Server: proftpd
  • POP3/POP3s/IMAP/IMAPs: Maildir format Courier-POP3/Courier-IMAP
  • Webalizer for web site statistics
  • Database: MySQL version 4.0
  • FastCGI Library 2.40
  • Ruby 1.82 with MySQL support.
  • Ruby GEM 0.8.11
  • Rails 1.1.2

This HOWTO is based mainly on The Perfect Setup -- Debian Sarge (3.1) by Falko -- consult that HOWTo for basic Debian Network Install Setup. The following sources were used or consulted:

Assuming you have an up and running basic Debian NetInstall (First two pages of Perfect Setup above) do the following:

Install your favorite editor

I like the Joe editor and will use it in all the examples -- substitute you favorite editor, so:

apt-get install joe

Configure the network

Edit the /etc/network/interfaces file

joe /etc/network/interface

It will initially look like this:

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet dhcp

Change it to look like this (example uses 192.168.0.100)

# /etc/network/interfaces -- configuration file for ifup(8), ifdown(8)
# The loopback interface
auto lo
iface lo inet loopback

# The first network card - this entry was created during the Debian installation
# (network, broadcast and gateway are optional)
auto eth0
iface eth0 inet static
address 192.168.0.100
netmask 255.255.255.0
network 192.168.0.0
broadcast 192.168.0.255
gateway 192.168.0.1

For multiple ips just add a new ip block like this (example uses 192.168.0.101)

# /etc/network/interfaces -- configuration file for ifup(8), ifdown(8)

# The loopback interface
auto lo
iface lo inet loopback

# The first network card - this entry was created during the Debian installation
# (network, broadcast and gateway are optional)
auto eth0
iface eth0 inet static
address 192.168.0.100
netmask 255.255.255.0
network 192.168.0.0
broadcast 192.168.0.255
gateway 192.168.0.1

auto eth0:0
iface eth0:0 inet static
address 192.168.0.101
netmask 255.255.255.0
network 192.168.0.0
broadcast 192.168.0.255
gateway 192.168.0.1

Then Restart the network

/etc/init.d/newtorking restart

Edit /etc/resolv.conf to add nameservers -- substitute your name server addresses:

joe /etc/resolv.conf

search server
nameserver 216.47.224.66
nameserver 216.47.224.68
nameserver 207.217.77.82
nameserver 207.217.120.82
nameserver 207.217.126.81

Edit /etc/hosts and add your new IP address

joe /etc/hosts

127.0.0.1       localhost.localdomain   localhost       server1
192.168.0.100 server1.example.com server1
192.168.0.101 virtual-ip1.example.com virtual-ip1

# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

Set the host name

echo server1.example.com > /etc/hostname
/bin/hostname -f /etc/hostname

Install some software we will need later on and remove some packages we do not need

apt-get install wget bzip2 rdate fetchmail libdb3++-dev unzip zip ncftp xlispstat libarchive-zip-perl zlib1g-dev libpopt-dev nmap openssl lynx fileutils
apt-get remove lpr nfs-common portmap pidentd pcmcia-cs pppoe pppoeconf ppp pppconfig

Update services started by inetd

update-rc.d -f exim remove
update-inetd --remove daytime
update-inetd --remove telnet
update-inetd --remove time
update-inetd --remove finger
update-inetd --remove talk
update-inetd --remove ntalk
update-inetd --remove ftp
/etc/init.d/inetd reload

Share this page:

6 Comment(s)

Add comment

Comments

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

Permissions:

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

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

# 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
/usr/local/bin/ruby
#if this is your path then the first line of your dispatch files would look like this

#!/usr/local/bin/ruby/

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.