Matt Connolly's Blog

my brain dumps here…

Redmine: Ruby on Rails without Virtual Hosts

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.

Advertisements

4 responses to “Redmine: Ruby on Rails without Virtual Hosts

  1. Pingback: install ruby on rails and redmine on ubuntu « ́‘¤~

  2. Arnaud 10 December, 2012 at 20:42

    YEAH ! Thank you so much for this little tutorial, these virtualhosts started to drive me crasy, and thanks to you, i’ve been able to make redmine available, along with my other services… And the whole thing in 30 seconds.

    Thanks again !
    Arnaud.

  3. Mike 31 May, 2013 at 21:57

    Thank you! This has been bothering me for DAYS! So helpful.

    In my own experience (to bring this up to date with May 2013):
    * You do not need the PassengerRoot and PassengerRuby parameters
    * PassengerEnabled should be set to “Off”, not “false”
    * If RailsBaseURI doesn’t work, try RackBaseURI

    Thanks again!

  4. Pingback: Install Redmine as a Sub-URI | NIXETRA

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: