mahiwaga

I'm not really all that mysterious

mephisto on Mac OS X

Currently, I am actually running a copy of Mephisto on my sister’s MacBook. Navigating the interface seems marginally faster than interacting with a remote copy on Dreamhost, but that could all be placebo effect. The main reason I wanted to do this is because I didn’t want to have to SSH into my shell account on Dreamhost for troubleshooting purposes. To be fair, it seems like they’ve taken care of their networking issues and the massive amounts of latency is now gone, but still.

It has been something of an excruciating pain in the ass adventure to get Ruby on Rails running locally. I just want to make sure I document the steps I took, just in case I have to do something like this again.

The first step was to get virtual hosting to run on Mac OS X. Now, the easier, sane thing to do is to just install Locomotive, which would’ve surely saved me at least a couple of hours.

Being lazy, I decided to just try and use Patrick Gibson’s shell script to create/remove virtual hosts from the default Apache install in Mac OS X. Note that this article is four years old, and as such, I don’t know if they changed something in Mac OS X 10.4 “Tiger”. Suffice it to say, I couldn’t get it to work.

My fallback was to follow the instructions I blogged about once upon a time on how to create virtual hosts on Mac OS X from the command line. Unfortunately, this blog post has a few errors in it. In Step 7, the vhost file in /etc/httpd/virtualhosts should actually have:

<VirtualHost 127.0.0.1>
DocumentRoot "/Users/$USERNAME/Sites/$VHOSTNAME"
ServerName $VHOSTNAME   # This is the corrected line
<Directory "/Users/$USERNAME/Sites/$VHOSTNAME">
Options Indexes FollowSymLinks ExecCGI
AllowOverride All

I checked out a copy of Mephisto via svn and put it in my ~/Sites folder. But it seems that mephisto behaves best when its public directory is installed as the document root, so this becomes as follows:

<VirtualHost 127.0.0.1>
DocumentRoot "/Users/$USERNAME/Sites/$VHOSTNAME/mephisto/public" 
ServerName $VHOSTNAME
ErrorLog /Users/$USERNAME/Sites/$VHOSTNAME/mephisto/log/error.log
    # ErrorLog directive keeps the log files under the mephisto directory
<Directory "/Users/$USERNAME/Sites/$VHOSTNAME/mephisto/public">
Options Indexes FollowSymLinks ExecCGI
AllowOverride All

NOTE: These directories must exist, otherwise Apache will choke when you restart. Also note the addition to keep the log file for this virtual host under the mephisto directory.

Note also that the default config of Apache on Mac OS X needs tweaking if you want this to work.

In particular, you will need to enable CGI/FCGI scripts to run from anywhere by making sure the following lines are somewhere in /etc/httpd/httpd.conf:

AddHandler fastcgi-script .fcgi
AddHandler cgi-script .cgi

But before you restart Apache, you’ll also have to install fast-cgi. (Also see Bringing Ruby on Rails with FastCGI into Mac OS X Server)

I used the following method, which will automatically insert the proper directives to load the module in your /etc/httpd/httpd.conf file:

apxs -o mod_fastcgi.so -c *.c
sudo apxs -i -a -n fastcgi mod_fastcgi.so

This was still not enough to get it to run. Apache’s error log revealed this rather cryptic message:

[Mon Aug 20 17:12:49 2007] [alert] [client 127.0.0.1] (2)No such file or 
directory: FastCGI: failed to connect to (dynamic) server 
"/Users/anyonecanuse/Sites/disorder.localhost/mephisto/public/dispatch.fcgi"
: something is seriously wrong, any chance the socket/named_pipe directory
was removed?, see the FastCgiIpcDir directive

After some truly desparate Googling, I realized that I needed to add this to /etc/httpd/httpd.conf:

FastCgiIpcDir /tmp/fcgi_ipc/

After stopping and restarting Apache a few times, I finally got it to work, successfully getting Mephisto to run, which promptly greeted me with the infamous 500 error. Now we’re getting somewhere.

The fastcgi crash log revealed that it would crash out on a call to Liquid::For:

As of the last revision of Mephisto (2953), the Liquid plugin is broken for some reason. All you have to do is update it like so:

rm -rf ./vendor/liquid
./script/plugin install http://liquid-markup.googlecode.com/svn/trunk
mv ./vendor/trunk ./vendor/liquid

I managed to get past this error, only to run into the following problem:

undefined method `extract_options!'

This is due to a fix for a problem caused by a change from Rails 1.2.3 to Edge Rails. This fix therefore makes it Mephisto trunk incompatible with Rails 1.2.3, and simply reverting the method call didn’t work for me for some reason. The true fix is simply to install Edge Rails.

rake rails:freeze:edge

Voilà! Revision 7359 seems to work like a charm. Remember to kill all your fastcgi threads. And empty your webcache for good measure.

Next up: transitioning back from Movable Type 4.0. Ah. Fun times.

initially published online on:
page regenerated on: