Neil Turner's Blog

Blogging about technology and randomness since 2002

Running Movable Type on OS X with FastCGI

Update (18th Jan 2007): Since this article was written in December 2005, Six Apart have released Movable Type 3.34 which has much improved FastCGI support and a better set of instructions for running it under FastCGI. I would therefore suggest that you follow Six Apart’s guide, rather than my own, but it will remain here for reference or if you wish to try this with an older copy of MT.

This is probably a bit niche, but it is in fact possible to run Movable Type under FastCGI on Mac OS X, since I’ve just got it up and running. For the curious, the guide is presented in the extended entry.

Step 1: Install Movable Type

I’m not going to go into any real detail here since there’s a very good guide here which tells you how to get MT 3.1 running with SQLite. Also have a look at my extra notes which mention the differences in procedure between MT 3.1 and 3.2 (which isn’t a lot).

Step 2: Install FastCGI

By default Mac OS X uses bog standard CGI, which is quite slow, especially when working with big Perl applications like Movable Type. You’ll need to install FastCGI separately.

You’re going to need to download two packages – FastCGI itself and mod_fastcgi (both link to the actual files). The latter is the Apache module that links FastCGI with your web server on your Mac. We’ll install FastCGI first. Unpack both files, then open a terminal and type the following:

./configure --prefix=/usr/local
sudo make
sudo make install

Next, we need to install mod_fastcgi:

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

Step 3: Install the FCGI Perl module

Movable Type includes the CGI::Fast module as standard, but you will need to install FCGI. To do this, type the following in the Terminal:

sudo cpan
install FCGI

FCGI includes some compiled binaries so you have to run it as root, hence the need for sudo.

Step 4: Configure Apache

You’ll need to paste the following in your /etc/httpd/httpd.conf file:

<IfModule mod_fastcgi.c>
FastCgiIpcDir /tmp/fcgi_ipc/
AddHandler fastcgi-script .fcgi

For this, I use vi – type sudo vi /etc/httpd/httpd.conf, then ‘i’ to enter edit mode. Paste this code somewhere (towards the bottom preferably), then press ESC, followed by :wq to save the file and quit.

Step 5: Make the FastCGI temp folder writable

This is just a little problem I encountered. Become root, and then do chmod 777 /tmp/fcgi_ipc and chmod 777 /tmp/fcgi_ipc/dynamic . Without this, Apache would fail to start.

You now need to restart Apache for FastCGI to become available – type sudo apachectl graceful in Terminal. Request a web page on your machine to check if Apache restarted correctly – if it does, great; otherwise open the Console application and choose /var/log, httpd and then open error_log to see what happened.

Step 6: Enable FastCGI in MT’s folder

Open your MT folder and edit the .htaccess file. Add these two lines:

AddHandler fastcgi-script .fcgi
FastCGIConfig -autoUpdate -idle-timeout 120 -killInterval 3600 -maxClassProcesses 3 -maxProcesses 15

The first line allows you to run files as FastCGI scripts and the second sets the timeout levels. It’s set for low-traffic environments, but I found that without it my scripts just timed out with Internal Server Error messages.

Step 7: Create a dispatch file

Go to Brad Choate’s guide for setting up MT on FastCGI on LightTPD and copy the second piece of code called dispatch.cgi and save it as mt.fcgi. You will need to modify it a bit; specifically add use lib "lib"; before the other ‘use: …’ statements, and then after the use statements add:

$ENV{"PERL5LIB"} = "/path/to/mt/lib";
$ENV{"MT_HOME"} = "/path/to/mt";
$ENV{"MT_CONFIG"} = "/path/to/mt/mt.cfg";

In this example, /path/to/mt is the path to your MT installation. In my case it is /Library/WebServer/CGI-Executables/mt and it’s quite possible that yours will be too. Make sure that mt.fcgi is executable by anyone (chmod a+x mt.fcgi).

Step 8: Enable peripheral scripts

This step is to ensure that MT’s peripheral scripts also use FastCGI – at the moment we’re just using FastCGI for the admin interface. Type the following commands in Terminal:

ln mt.fcgi mt-comments.fcgi
ln mt.fcgi mt-tb.fcgi
ln mt.fcgi mt-search.fcgi
ln mt.fcgi mt-view.fcgi
ln mt.fcgi mt-atom.fcgi

Finally, open mt.cfg or mt-config.cgi (depending on your MT version) and paste these lines in:

AdminScript mt.fcgi
CommentScript mt-comments.fcgi
TrackbackScript mt-tb.fcgi
SearchScript mt-search.fcgi
ViewScript mt-view.fcgi

And that’s it! With a bit of luck, MT will now run much more quickly on your Mac.

Please note that this is just a rough guide, and while this worked fine on my Mac (running OS X Tiger 10.4.3) it may not on yours. I’d also have been lost had it not been for BP’s Weblog, Brad Choate and Hivelogic Narrative which were highly useful when setting FastCGI up on my machine. Much of this article is based on their work.


  1. Wow. You just saved me quite a bit of work, and even more frustration. Thanks, Neil!

  2. Running Movable Type on OS X with FastCGI

    Neil zeigt in seinem Beitrag wie man mit etwas Geschick auf dem Mac Movable Type auch unter fastcgi laufen lassen kann. Sehr speziell von den Anforderungen aber für Movable Type Anwender gewiss bookmarkverdächtig.

  3. Запуск Movable Type через Fast CGI под Apache

    Введение Итак, здесь я расскажу, как запускать backend Movable Type’а в режиме FastCGI, вместо просто CGI. Для начала — различия между CGI и FastCGI. Предпол�…

  4. Movable Type, apache y FastCGI

    Mejorando el rendimiento de Movable Type con FastCGI

  5. Straightforward and comprehensive! Thanks

  6. Thanks for this Neil – very helpful.
    I had one problem. When installing mod\_fastcgi I got an error “cp: No such file or directory”. So I followed the instructions with the download and did this instead:

    cp Makefile.AP2 Makefile
    make top_dir=/usr/share/httpd
    sudo make install top_dir=/usr/share/httpd

    /usr/share/httpd is where my apache2 stuff is — I’m not sure if this is standard on OS X or not.
    I also seemed to have to uncomment this line:

    #LoadModule fastcgi_module libexec/apache2/

    in /private/etc/apache2/httpd.conf or else I got Internal Server Errors.
    I *think* it works now — there are no errors and Apache says “mod_fastcgi/2.4.6 configured” when starting up — but MT seems no quicker, so I’m not entirely convinced!