Wednesday, August 18, 2010

Movable Type 5.x on GlassFish 3.x

Image representing Movable Type as depicted in...Image via CrunchBase

As a number of you know I have done articles on connecting Drupal on GlassFish. The same procedure would work for WordPress on GlassFish using Quercus.

This is a change of track; Movable Type is a Common Gateway Interface (CGI) based application on Perl. GlassFish provides a means, in fact, a default for executing cgi-bin applications and specifically by default Perl.

I am a fan of Movable Type. Perhaps it stems from my earlier years as a developer using Perl. The movable type tags are familiar and follow a JSP/JSF tag library paradigm which also makes its use feel more native to me. So I spent the weekend tweaking the process. I will not move this blog to it since so many of you know where it is at, but I am going to move my personal blog on to it.

Software Requirements:

Movable Type 5.02
GlassFish 3.0.1
NetBeans 6.9.1
MySQL 5.x
Perl 5.8.1+ (OS X 10.6 has Perl 5.10)


The first step is to examine the requirements from Movable Type on which Perl modules are required to run the application. There are also a number of additional modules listed for more functionality. You can add these later as you need them, or be proactive and download them in advance. I will not repeat the requirements from the Movable Type site, but here is a link: Perl Modules.


The MySQL portion simply is installing the database software, creating a database, and adding a user. It is very straight forward.
  1. Install MySQL 5.x.
  2. Create movable type database. From a mysql prompt:

    create database movable_type character set utf8;

  3. Create database user.

    GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON movable_type.* TO 'movable_type'@'localhost' IDENTIFIED BY 'movable_type';

    Note: Do not do this in production!

Movable Type 5.x

  1. Download Movable Type 5.02
  2. Unzip the files.
  3. Change the name from MT-5.02 to mt
  4. Change permissions on the mt-static/support directory to 777, or 755 if the application server owns the directory.
    chmod 777 mt-static/support
  5. Create a directory called WEB-INF in the mt directory
NetBeans 6.9.1

  1. Download and Install NetBeans 6.9.1.
  2. Create a new Web Project from Existing Sources.

  3. Name the project mt-project to keep it separated from project code.

  4. Select the directory where the source (.cgi files) are located.
  5. Select the WEB-INF directory you created previously. Alternatively you can download my pre-configured files including the web.xml files here.

  6. The project should be complete and look like the following.

  7. Create a web.xml file which will contain the servlet information needed to run the CGI based applications. Alternatively you can download my pre-configured files including the web.xml files here. The file should contain the following:

    <?xml version="1.0" encoding="UTF-8"?>
    <web-app version="3.0" xmlns="" xmlns:xsi="" xsi:schemaLocation="">
    <description>This is a dummy web.xml file that configures GlassFish 3.x to handle Common Gateway Interface (CGI) applications. Specifically, it is configured for Movable Type 5.x.
    If you need to set additional parameters, please see the default-web.xml file located in the domainX/config directory.
    <display-name>Movable Type 5.x Web Project</display-name>
    <description>Default GlassFish Common Gateway Interface (CGI) Servlet</description>
    <description>0 = Off 1 = On
    <description>A required parameter. It defaults to perl.</description>
    <description>You may change this to point where the *.cgi
    files are located. This sets the path to the main
    project directory. The default is WEB-INF/cgi
    <!-- This is set to point to the default Movable Type application -->
  8. This completes the project.
    Note: You will not be creating a .war file for the application since this will remove the permissions, and executable flags from the *.cgi scripts.
  9. Close the application and move it to a directory location of your choosing for example /usr/local/mt.
GlassFish 3.x

  1. Download and Install GlassFish 3.0.1
  2. Start the application server and verify that it is running correctly.
  3. Deploy the Movable Type application

    asadmin deploy /usr/local/mt

  4. Examine the application from the GlassFish administration. You should see it deployed as an application.

  5. Launch the Configuration Wizard. http://localhost:8080/mt/cgi-bin/mt-wizard.cgi

  6. Set the location of the mt-static static web path. I changed mine to http://localhost:8080/mt/mt-static/
  7. Ensure that the mt-static absolute path is correct.
  8. The next step checks to make sure all of the required Perl modules are installed. If it shows any requirements missing, install them before continuing. This is a clean example.

  9. Configure the database. In this case everything is called movable_type.
    Note: Do not do this in production.

  10. Test the connection. If the connection is successful, you should see the screen below.

  11. Next configure Email. The example below is a representative sample where I chose Sendmail.

  12. Test email.

  13. Congrats! You have configured Movable Type!

  14. Configure your account (Administrative Account).

  15. The next set of steps can be customized depending on how you want to deploy web sites, and blogs to your GlassFish instance. This example will install the files in the document root on the server to make it the default site and blog. Configure your site. Please note in the image below, I have set the root to http://localhost:8080 and the file location to the ../domains/domain1/docroot folder

  16. Click Finish Install

  17. Click on your website and add any parameters you need to set, and click on publish.
    Note: If you don't publish, the site will not be available.

  18. Check out your new Movable Type site!

I hope you enjoyed this tutorial, and will take advantage of Movable Type for creating a web site and blogging.

A great article which describes a lot of detail around CGI on GlassFish v2 and v3 was done by Shing Wai Chan called Common Gateway Interface in GlassFish. His blog explains the Common Gateway Interface (CGI) Servlet in GlassFish, and without it none of this is possible.

Enhanced by Zemanta


Popular Posts