The development setup that we tested this under was a server that running Red Hat Enterprise 3, cPanel, Apache 1.3.33
Install Ruby:
(You can grab the latest source package from http://ruby-lang.org/en/20020102.html)
$ cd /usr/local/src
$ wget ftp.ruby-lang.org/pub/ruby/ruby-1.8.2.tar.gz
$ tar -xvzf ruby-1.8.2.tar.gz
$ cd ruby-1.8.2
$ ./configure && make && make install
Next Ruby Gems:
(Latest version and localized mirrors here http://rubyforge.org/frs/?group_id=126)
$ cd /usr/local/src
$ wget rubyforge.org/frs/download.php/3700/rubygems-0.8.10.tgz
$ tar -xvzf rubygems-0.8.10.tgz
$ cd rubygems-0.8.10
$ ruby setup.rb
Once Gems are installed its a whirl to install Rails:
$ gem install rails
(Answer Y to all the dependancies)
Now for Fast CGI and getting it to play nicely with Apache.
Install Fast CGI:
(‘Sourced’ from http://fastcgi.com/dist/)
$ cd /usr/local/src
$ wget fastcgi.com/dist/fcgi-2.4.0.tar.gz
$ tar -xvzf fcgi-2.4.0.tar.gz
$ cd fcgi-2.4.0
$ ./configure && make && make install
And mod_fastcgi for Apache 1.3+
$ cd /usr/local/src
$ wget fastcgi.com/dist/mod_fastcgi-2.4.2.tar.gz
$ tar -xvzf mod_fastcgi-2.4.2.tar.gz
$ cd mod_fastcgi-2.4.2
$ /usr/local/apache/bin/apxs -o mod_fastcgi.so -c *.c
$ /usr/local/apache/bin/apxs -i -a -n fastcgi mod_fastcgi.so
Now for Ruby fcgi:
$ gem install fcgi
You now need to edit your Apache config file.
By default its (/etc/httpd/conf/httpd.conf)
Add these lines:
LoadModule fastcgi_module libexec/mod_fastcgi.so
<IfModule mod_fastcgi.c>
FastCgiIpcDir /tmp/fcgi_ipc/
AddHandler fastcgi-script .fcgi
</IfModule>
Make sure /tmp/fcgi_ipc/ is writable and executable by Apache (Apache runs as ‘nobody’ on our servers, this may differ for you)
$ chown nobody.nobody /tmp/fcgi_ipc -R
$ chmod 755 /tmp/fcgi_ipc -R
Now restart Apache:
$ /etc/rc.d/init.d/httpd restart
You can test Ruby-on-Rails out by creating a test virtual host:
Add rails.yourdomain.com to DNS
Add a new host for the rails test app
$ vi /usr/local/apache/conf/httpd.conf
On Apache2 it should looks like:
<VirtualHost *:80>
ServerName rails.yourdomain.com
ServerAdmin robin-rails@yourdomain.com
ErrorLog logs/rails.yourdomain.com-error_log
CustomLog logs/rails.yourdomain.com-access_log combined
DocumentRoot /home/apache/yourdomain.com/rails/live/public/
<Directory /home/apache/yourdomain.com/rails/live/public/>
Options ExecCGI FollowSymLinks
AllowOverride all
Allow from all
Order allow,deny
</Directory>
</VirtualHost>
Create a test app:
$ cd /home/apache/yourdomain.com/rails
$ rails test
$ ln -s test live
$ cd live
$ chown -R nobody:nobody .
$ vi public/dispatch.fcgi
Replace "require 'fcgi'" with:
require 'rubygems'
require_gem 'fcgi'
$ vi public/.htaccess
Change "RewriteRule ^(.*)$ dispatch.cgi [QSA,L]" to:
RewriteRule ^(.*)$ /dispatch.fcgi?$1 [QSA,L]
$ chmod 755 public/dispatch.fcgi
$ chmod 755 public/.htaccess
Check it out:
http://rails.yourdomain.com