The Post
Serving Ruby on Rails with Apache2 and mod_fcgid on Leopard
This tutorial will show you how to install and configure mod_fcgid on your system so you can serve Ruby on Rails applications with the Apache2 Web server.
For this tutorial we assume that you are running a custom installation of Apache2 located at /usr/local/apache2 with Leopard's Ruby on Rails native installation. If you want to use Leopard's Apache2 installation, you'll have to change the paths in the mod_fcgid Makefile to point to Leopard's Apache2 installation directories.
1. Installing mod_fcgid
Download mod_fcgid source code from http://sourceforge.net/projects/mod-fcgid/
Extract into /usr/local/src
% cd /usr/local/src/mod_fcgid.2.2
% make
% sudo make install
Configuring Apache
% nano /usr/local/apache2/conf
% sudo nano httpd.conf
Add the following at the end of the LoadModule list
LoadModule fcgid_module modules/mod_fcgid.so
Scroll down to the end of the httpd.conf file and make sure that the following line is not commented:
<IfModule mod_fcgid.c>
AddHandler fcgid-script .fcgi
IPCCommTimeout 40
IPCConnectTimeout 10
SocketPath /var/tmp/fcgidsock
</IfModule>
Include conf/extra/httpd-vhosts.conf
Save and close httpd.conf
Installing fcgi gem
% sudo gem install fcgi
Add a virtual host for your Rails application
% sudo nano /usr/local/apache2/conf/extra/httpd-vhosts.conf
Add the following lines at the end of the file:
Listen 4000
<VirtualHost *:4000>
DocumentRoot "/Path/to/Rails/app/public"
<Directory "/Path/to/Rails/app/public">
AddHandler fcgid-script .fcgi
Options +ExecCGI +MultiViews +FollowSymLinks
AllowOverride All
order allow,deny
allow from all
</Directory>
</VirtualHost>
* Please replace /Path/to/Rails/app/ with the real path to your Rails application.
Restart Apache
In the .htaccess file of your Rails application, please comment out the following 2 lines:
#AddHandler fastcgi-script .fcgi
And change
#AddHandler cgi-script .cgi
RewriteRule ^(.*)$ dispatch.cgi [QSA,L] to RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]
Now, if you browse to http://localhost:4000/ you should see your Rails application up and running
The Posts
- Moosort - Mootools table-sorting
- Multi-format Web media player
- Moopick - Mootools-based Color Picker
- Moobox - Mootools-based Modal Window
- Serving Ruby on Rails with Apache2 and mod_fcgid on Leopard
- Setting up Apache, MySQL and PHP 5 with GD support on Leopard
- IE6 Transparent PNG and Dead Links
- Image Replacement For Form Buttons