In March, I’ve set up a Redmine application with the Ruby webserver Webrick. Since then, I’ve migrated to Apache, and then the question was: Which Ruby bridge module to use? It’s not that the choice is large, you have mod_fastcgi, mod_fcgid and mod_rails a.k.a. Passenger. I’ve tried the three of them, and only one was a success.
As for the last post about Redmine, I’ve compiled everything (Apache included) in a custom location and I start the server from there (without root rights).
mod_fastcgi
This is an old module, but it should be easy to use.
After setting up the configuration file to get the public/dispatch.fcgi file, Ive started the server (did I say that Ruby does a wonderful job by providing every wrapper file needed for any webserver? It provides cgi and fcgi skeletton files, and of course everything needed for Webrick). Unfortunately, it didn’t work, it misses the rubygem module, although it is installed as I’ve used it to install Ruby on Rails!
So I left mod_fastcgi where it was, in the dust.
mod_fcgid
This module is based on Fast CGI as well, but is more recent than mod_fastcgi. It uses Unix socks for the communications between Apache and the back-end, and in my configuration, the server didn’t seem able to create socks (I didn’t find a reason on the Internet, but I have to say I didn’t look far, and besides Google has not much to say about this issue. And I still have Passenger). So much for this module.
Passenger
This module is supposed to interact directly with the ruby files, and in fact it does. No need to have a dispatch.fcgi file, it calls the server as Webrick does.
I’ve installed rake with a gem, but Passenger setup didn’t find it, I had to add a symbolic link between lib/ruby/gems/1.8/bin/rake and bin/rake. I’ve installed fastthread as well, and I was good to go.
In the configuration file, I load the appropriate modules:
LoadModule passenger_module /web/src/passenger-2.2.2/ext/apache2/mod_passenger.so PassengerRoot /web/src/passenger-2.2.2 PassengerRuby /web/bin/ruby
Then I can configure the Virtual Host:
NameVirtualHost *:3000 <VirtualHost *:3000> DocumentRoot /src_custom/redmine-0.8.3/public <Directory /src_custom/redmine-0.8.3/public> AllowOverride None Order allow,deny allow from all Options Indexes FollowSymLinks MultiViews </directory> ErrorLog /web/logs/error.log LogLevel warn CustomLog /web/logs/access.log combined ServerSignature On </VirtualHost>
Conclusion
With Passenger, it was really easy to have a working configuration. The only thing I’m still missing is the ability to set the RAILS_ENV variable to select a different environment than the default (production).
Same experience with Redmine 2.2 and apache 2 onn CentOS 5.8; after trying with mod_fastcgi and mod_fcgid and having no success, I’ve installed Passenger.
The setup was easy:
cd $REDMINE_HOME
gem install passenger
passenger-install-apache2-module
modify httpd.conf as instructed by the previous script
delete the file $REDMINE_HOME/public/.htaccess
restart apache