installing mod_ruby on os x with apache 228
Tue, Jan 20, 2009
One of the biggest problems I have with Ruby is it’s lack of Apache support. PHP is just so easy to use with Apache but as I also want to learn about Ruby I thought I’d take the hit and try and install modruby. As ever with Ruby, it’s not easy. The site constantly disappears and it’s pot luck whether you get there:
Firefox can’t find the server at www.modruby.net.Apparently it’s also not very good with Apache 2.2 but seems to be not too bad for my newbie investigations. I always create a configure script when building something so I know how to do it again. For mod_ruby, this is my configure_mod_ruby script:
./configure.rb –with-apxs=/Users/alistair/apps/httpd-2.2.8/bin/apxsthe first option was fine, it found apxs. The second I added after it barfed big time on apr.h, or lack thereof. However, even pointing at my apr binary or source install still caused it to barf on apr-config.h and a host of other apr things. Eventually I found this page and did:
locate apr.hwhich came up with the SDK path to apr-1, which solved all build problems. Adding the config options from example/httpd.conf to my apache conf and doing:
apachectl configtestsaid apache was fine with the mods. So, I created a ruby-scripts directory in my DocumentRoot, bunged index.rbx into it with the contents:
puts “Hello World!”added this:
<IfModule mod_ruby.c> … DirectoryIndex index.rbxrestarted apache, accessed /ruby-scripts and got the error:
… ruby-scripts/: Is a directoryyou don’t say! Clearly DirectoryIndex was being ignored and lo and behold /ruby-scripts/index.rbx produced a different error:
… ruby-scripts/index.rbx failed for (null), reason: file permissions deny server executionso next step was to add exec to the file:
chmod +x index.rbxand finally “Hello World” was displayed!
So there’s now a completely new development effort open to me. Dojo + Ruby. Can’t wait!