Gentoo, Rails and mod_fcgid
My friend Marcel asked me about my Gentoo, Rails and mod_fcgid configuration.
Here it is:
Software versions:
- apache-2.2.6
- mod_fcgid 1.10
- rails 1.2.5
Content of the .htaccess file inside the public directory of the rails application:
Options +FollowSymLinks +ExecCGI
RewriteEngine On
RewriteBase /
RewriteRule ^$ index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]
ErrorDocument 500 "<h2>Application error</h2>Rails application failed to start properly"
Example vhost entry:
<VirtualHost *:80>
ServerAdmin webmaster@domain.tld
DocumentRoot "/var/www/www.domain.tld/public/"
ErrorLog /var/www/www.domain.tld/log/apache.log
ServerName domain.tld
Serveralias domain.tld
<Directory "/var/www/www.domain.tld/public">
Options ExecCGI FollowSymLinks
AddHandler fcgid-script .cgi .fcgi .fcg
AllowOverride all
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Last things to do:
Make sure that the rails tmp directory is writeable by the webserver.
Do not forget to run apache with mod_fcgid enabled. Edit /etc/conf.d/apache and add ' -D FCGID ' to the APACHE2_OPTS. Then restart the webserver with /etc/init.d/apache2 restart .
I removed dispatch.cgi to be sure that dispatch.fcgi is used.
mod_fcgid ruby on rails gentoo
