I’ve been playing around with Redmine, a Rails app, on Mac OS X 10.6. It’s been quite a pain to get set up. It seems that the only easy way to get passenger to work is with virtual hosts. It’s not really obvious or intuitive how virtual hosts work. After a lot of RTFMing the apache docs, and passenger google group, I got it working. But Virtual hosts are still a pain, because you have to set them up in your /etc/hosts file more for every machine on the network, and there’s still a high likelihood of breaking other things (like php apps)
So, is it possible to install redmine (or any ruby on rails app) in a directory without using a separate virtual host just for the app, AND without taking down other php apps (drupal, phpmyadmin, etc) which are running on the same apache server?
Yes. After lots of trial and error, the solution is fairly simple, but has to be done in a specific way.
Step 1. Configure httpd.conf files
Add this to your httpd.conf file, (or an included file) before your users/other conf files are loaded:
LoadModule passenger_module /Library/Ruby/Gems/1.8/gems/passenger-2.2.15/ext/apache2/mod_passenger.so
PassengerRoot /Library/Ruby/Gems/1.8/gems/passenger-2.2.15
PassengerRuby /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
PassengerEnabled Off
Follow the passenger install instructions to make sure that you’ve got the right paths and versions in there. “PassengerEnabled Off” in the global scope disables it by default. We’ll enable it just for where we want it.
Step 2. Setup a .conf file for the rails app
In my case, I’ve added a “redmine.conf” file which is imported by httpd.conf. In this file, I have:
<Location "/redmine">
Options Indexes ExecCGI FollowSymLinks -MultiViews
Order allow,deny
Allow from all
AllowOverride all
PassengerEnabled On
RailsBaseURI /redmine
RailsEnv production
</Location>
Here we enable Passenger, set the rails environment and the rails base URI.
Step 3. Setup a symlink
I had tried this with real directories and apache “Alias” commands to no luck. The passenger module docs does have instructions, but only for use with virtual hosts, if you ignore the virtual hosts bit, it works. On the mac, I have it set up like this:
$ # /Library/WebServer/Documents -- document root
$ # /Library/WebServer/Sites -- for rails and other apps.
$ cd /Library/WebServer/Documents
$ ln -s ../Sites/redmine/public redmine
Finally, a solution that other network machines can access without Virtual Host nightmare.