Ruby on Rails on Arch Linux with Mongrel and Apache

I’ve spent the last week or so trying to get a Ruby on Rails up and running on my Arch Linux box. I was determined to get something ‘better’ than WEBrick running to allow me to have production(ish) environment. I also wanted to achieve side by side with LAMP configuration I’m running to serve this (wordpress) blog.

I started off looking at using Apache with mod_fastcgi, which for the life of me, I couldn’t get the module to compile at all. I tried numerous PKGBUILDs from other archers but none seem to compile.

I then looked to Apache with mod_fcgid which is supposed to be better for Apache2 installations over mod_fastcgi. I had a little more success with this but overall it didn’t work. I successfully created my own Arch package for this which seemed to install OK, I just never seemed to get it ‘talking’ to rails properly 😦

I then started to read some stuff about Mongrel which looked interesting. No FCGI but with speed 😀 I actually was reminded about Mongrel while reading Amy Hoy’s article ‘Because let’s face it, WEBrick sucks‘ which showed my how easy it would be to use Mongrel. Thanks Amy 🙂

So, getting Mongrel working was fine, but I wanted to proxy the requests through apache so that I had only one webserver talking to the outside world. I found Hank Matter’s article ‘Successful settings for Apache forwarding to Mongrel‘ set me off in the right direction but actually discovered this was overly complex for my setup. It was actually alot easier than this to setup.

Hank seems to be setting it up so that a folder off your site proxys back to Mongrel and serves your rails content. If though, like me, you are using virtual hosts, the setup is simplified further.
It is just a case of adding this in your virtual host config –

Redirect / http://vhost.example.com/
ProxyPass / http://localhost:3000/
ProxyPassReverse / http://localhost:3000/

That’s it, Apache is now proxying back to Mongrel 🙂

Advertisements

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s

%d bloggers like this: