Virtual Hosting and Movable TypeSaturday, May 2, 2009
It was a lot harder than I anticipated to get Movable Type to run from a single global install on all of my virtually hosted domains. So in the spirit of sharing, here’s how I did it.
First, install movable type into a directory at the root of your web servers directory structure. I put mine in /var/www/shared/. The resulting directory structure contained:
- This directory contains pretty much everything in the Movable Type tarball.
- This directory is the mt-static directory from the Movable Type tarball. I moved it out to the top level of the shared directory because I have Apache configured to not serve documents from the cgi-bin directory.
- This directory will contain the configuration files for all of the sites you will be virtually hosting.
Next configure apache for each of your virtually hosted domains. I assume you already have virtual hosting up and running. The configuration file for socialhacker.com looks like this:
<VirtualHost *:80> ServerName www.socialhacker.com ServerAlias socialhacker.com *.socialhacker.com DocumentRoot /var/www/socialhacker AddHandler cgi-script .cgi SetEnv MT_HOME /var/www/shared/cgi-bin/mt SetEnv MT_CONFIG /var/www/shared/conf/socialhacker.cgi ScriptAlias /cgi-bin/ /var/www/shared/cgi-bin/ Alias /mt-static/ /var/www/shared/mt-static/ </VirtualHost>
The important bits here are how you set up the alias’ and the environment variables. And all of this is covered in this article.
Finally, you need to create a configuration file in the shared/conf directry for your site. I did this by hand, which you’ll need to do as well since Movable Type won’t set most of these options in the configuration file it generates.
CGIPath /cgi-bin/mt/ StaticWebPath /mt-static/ StaticFilePath /var/www/shared/mt-static/ PluginPath /var/www/shared/cgi-bin/mt/plugins/ TemplatePath /var/www/shared/cgi-bin/mt/tmpl/ WeblogTemplatesPath /var/www/shared/cgi-bin/mt/default_templates/ ObjectDriver DBI::mysql Database <your database name> DBUser <your database user> DBPassword <your database password> DBHost localhost MailTransfer smtp SMTPServer smtp.<your provider>.com _(probably)_
And there’s the real magic. You have to specify paths to the Static content as well as both Template directories, and the Plugin directory. If you forget the first template directory you won’t get very far as the administrative pages won’t load. But if you forget the second template path you’ll get all the way to making a post and find that all of the files in your blog directory are zero length. If you forget the Plugin path you’ll be missing all of your plugins.
Hopefully you’ve found this useful in setting up your own Movable Type blogs.