Movable Type 5.2 on Mac OS X

It’s been a while since my notes about local development copies of Movable Type and WordPress on XAMPP – a local LAMP stack that runs on Windows. I’m still using both blogging platforms and wanted to update the steps now that I’m doing most of my work on a Mac laptop.

The steps below walk through the installation of a local copy of Movable Type 5.2 on Mac OS X.

These instructions assume you already have MySQL, PHP, Perl, and Apache installed. I believe most of these are present in stock OS X installations, but in my case I’ve upgraded everything manually to more recent versions:

  • Mac OS X 10.6.8
  • PHP 5.3.15
  • Perl 5.10.0
  • Apache 2.2.22
  • MySQL 5.5.17

As an alternative, you could use MAMP which is a packaged, pre-configured compilation of Apache, MySQL, and PHP. You may still need to upgrade some Perl modules, however, as Perl is not included in MAMP.

Important Note: In the instructions below I’m using a lot of settings which should not be used in a production environment (like having a MySQL root user with no password). Since this is a local dev environment, we can take a few shortcuts, but don’t do the same on a live site.

Apache

First we’ll set up Apache for our local hosting of Movable Type.

I’m going to host everything under my home directory: mkdir -p /Users/brian/mt/cgi-bin; chmod 777 /Users/brian/mt. We’ll use this path in the examples below, so change it accordingly for your system.

Next, edit the Apache configuration which is based in /etc/apache2. Edit httpd.conf and make the following changes:

  • Find and comment-out the line that starts: ScriptAliasMatch ^/cgi-bin/... (if present)
  • Add a line somewhere to include our custom config: Include /private/etc/apache2/extra/httpd-mt.conf

Under the /etc/apache2/extra location, create a new file httpd-mt.conf with the directory and virtual host settings:

<Directory "/Users/brian/mt">
AddHandler cgi-script .cgi
AllowOverride None
Options FollowSymLinks +ExecCGI Indexes
Order allow,deny
Allow from all
</Directory>
<VirtualHost *:80>
ServerAdmin brian@example.com
DocumentRoot "/Users/brian/mt"
ServerName localhost.mt
ErrorLog "/private/var/log/apache2/mt-error_log"
CustomLog "/private/var/log/apache2/mt-access_log" common
SetEnv DYLD_LIBRARY_PATH /usr/local/mysql/lib/
</VirtualHost>

Next, restart Apache: sudo apachectl -k restart.

Add our virtual host “localhost.mt” to the /etc/hosts file:

127.0.0.1 localhost.mt

To confirm that Apache is set up correctly, visit http://localhost.mt in a browser. Check /var/log/apache2/ to see content in both of the MT log files and confirm there are no errors.

MySQL

Next we’ll set up the MySQL user (mt), password (password) and empty database (mt) for Movable Type.

$ mysql -u root
mysql> create user 'mt'@'localhost' identified by 'password';
Query OK, 0 rows affected (0.07 sec)
mysql> grant all on mt.* to 'mt'@'localhost';
Query OK, 0 rows affected (0.04 sec)
mysql> create database mt default character set = utf8;
mysql> show grants for 'mt'@'localhost';
+-----------------------------------------------------------------------------------------------------------+
| Grants for mt@localhost                                                                                   |
+-----------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'mt'@'localhost' IDENTIFIED BY PASSWORD '*2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19' |
| GRANT ALL PRIVILEGES ON `mt`.* TO 'mt'@'localhost'                                                        |
+-----------------------------------------------------------------------------------------------------------+
mysql> exit;

Movable Type Download

In the instructions below we’ll download the latest open source Movable Type. (Similar steps could be followed for any of the commercial versions of Movable Type.)

The steps below use the Movable Type “Install via SSH” instructions if you want to follow on. The first step is to download and example the .zip file, then move and set up the directories:

$ wget http://www.movabletype.org/downloads/stable/MTOS-5.2.zip
$ unzip MTOS-5.2.zip
$ mv MTOS-5.2/* cgi-bin
$ cd cgi-bin
$ chmod 777 mt-static/support
$ chmod 777 themes
$ cd ..
$ ln -s cgi-bin/mt-static mt-static

Note: If your perl is in a location other than /usr/bin/perl, you will need to edit all of the .cgi files to change the first line.

Movable Type System Check

Now we run the Movable Type system checker script: http://localhost.mt/cgi-bin/mt-check.cgi

This script will check all the required Perl modules. Make sure your Perl configuration has all of the required modules and the database module you intend to use. (In this example I’m using MySQL.) Use Perl CPAN to install additional modules as required.

In my case the Perl modules were pretty straightforward except for DBD::mysql. I finally found the solution (including the SetEnv DYLD_LIBRARY_PATH in Apache config above) from this Stackoverflow answer about Perl CGI not working with MySQL.

Movable Type Configuration

Once we have all the required Perl modules in place, create a config file for MovableType. Copy mt-config.cgi-original to mt-config.cgi and set the appropriate values for the web paths and database settings:

CGIPath        http://localhost.mt/cgi-bin/
StaticWebPath  http://localhost.mt/mt-static
ObjectDriver   DBI::mysql
Database       mt
DBUser         mt
DBPassword     password
DBHost         localhost

With the configuration in place we can login to Movable Type for the first time: http://localhost.mt/cgi-bin/mt.cgi

The first step will create the admin login account and password. I suggest using your real email address here to test any of the system messages.

Next is the “Create your first Website” dialog. Make sure to set the website URL and root correctly using the paths above. For example, above we have the Movable Type files in /Users/brian/mt/cgi-bin, and the website root will be /Users/brian/mt.

Finally you should be able to log in to the Movable Type interface. Create a blog and publish it, then confirm you can view it with the local path provided.

Happy hacking!