Matt Connolly's Blog

my brain dumps here…

Monthly Archives: September 2010

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/
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

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.

Installing Redmine on Mac OS X 10.6

Following instructions here, I did this:

I already had a MySQL server running on my MacBook Pro, which was installed with the default mysql installer for mac os x. It installs into: /usr/local/mysql with its socket at /tmp/mysql.sock

sudo gem install rails -v=2.3.5
sudo gem install rack -v=1.0.1
sudo gem install rake
sudo gem install fastthread
sudo gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config

I then used phpmyadmin to create a database with a user. Easy to do in one step from the Privileges tab where you can add a user and create a database for them at the same time!

I had already done this step, but you may need to:

sudo ln -s /tmp/mysql.sock /var/mysql/mysql.sock


cd /Library/Webserver/Sites
svn checkout redmine
cd redmine
mkdir -p tmp public/plugin_assets
sudo chmod -R 755 files log tmp public/plugin_assets
cp config/database.yml.example config/database.yml
open -e config/database.yml

and enter the database name, username and password in the “production:” area. Then:

rake generate_session_store
RAILS_ENV=production rake db:migrate
RAILS_ENV=production rake redmine:load_default_data

And then launch the server from the command line

ruby script/server webrick -e production

So there it is: redmine running from ‘webrick’ (the test platform). Getting it running using cgi or mod_passenger is considerably more challenging, and for another article…

Ruby on Rails Virtual Host craziness

I followed the instructions for installing ruby with passenger from this blog:

I had a similar problem to Tom’s comment where all my web requests ended up being handled by passenger (mod_rails). RTFM’ing about virtual hosts found a solution for me:

The first virtual host becomes the main site. So you need a virtual host for “localhost” with ServerName localhost and DocumentRoot matching the main server DocumentRoot.

Otherwise the rails app will become the default, and the entire site will be handled by passenger. Most frustating.

iTunes 10 – Everything is disabled – Help!!!

I just upgraded to the new iTunes version 10, and everything is disabled. All the icons are grayed out and nothing works!!!

(sarcasm off) – seriously, what a Microsoft calibre U.I. blunder. Colour association is fundamental to navigation and recognition of icons. Now they’re all gray scale, not only do they all look disabled, they all look the same.

Epic fail, Apple.