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.
Movable Type 5.02
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.
- Install MySQL 5.x.
- Create movable type database. From a mysql prompt:
create database movable_type character set utf8;
- 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
- Download Movable Type 5.02
- Unzip the files.
- Change the name from MT-5.02 to mt
- Change permissions on the mt-static/support directory to 777, or 755 if the application server owns the directory.
chmod 777 mt-static/support
- Create a directory called WEB-INF in the mt directory
- Download and Install NetBeans 6.9.1.
- Create a new Web Project from Existing Sources.
- Name the project mt-project to keep it separated from project code.
- Select the directory where the source (.cgi files) are located.
- Select the WEB-INF directory you created previously. Alternatively you can download my pre-configured files including the web.xml files here.
- The project should be complete and look like the following.
- 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="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"> <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. </description> <display-name>Movable Type 5.x Web Project</display-name> <servlet> <description>Default GlassFish Common Gateway Interface (CGI) Servlet</description> <servlet-name>cgi</servlet-name> <servlet-class>org.apache.catalina.servlets.CGIServlet</servlet-class> <init-param> <description>0 = Off 1 = On </description> <param-name>debug</param-name> <param-value>1</param-value> </init-param> <init-param> <description>A required parameter. It defaults to perl.</description> <param-name>executable</param-name> <param-value/> </init-param> <init-param> <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 </description> <param-name>cgiPathPrefix</param-name> <param-value/> </init-param> <load-on-startup>5</load-on-startup> </servlet> <servlet-mapping> <servlet-name>cgi</servlet-name> <url-pattern>/cgi-bin/*</url-pattern> </servlet-mapping> <session-config> <session-timeout> 30 </session-timeout> </session-config> <welcome-file-list> <!-- This is set to point to the default Movable Type application --> <welcome-file>cgi-bin/mt.cgi</welcome-file> </welcome-file-list> </web-app>
- 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.
- Close the application and move it to a directory location of your choosing for example /usr/local/mt.
- Download and Install GlassFish 3.0.1
- Start the application server and verify that it is running correctly.
- Deploy the Movable Type application
asadmin deploy /usr/local/mt
- Examine the application from the GlassFish administration. You should see it deployed as an application.
- Launch the Configuration Wizard. http://localhost:8080/mt/cgi-bin/mt-wizard.cgi
- Set the location of the mt-static static web path. I changed mine to http://localhost:8080/mt/mt-static/
- Ensure that the mt-static absolute path is correct.
- 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.
- Configure the database. In this case everything is called movable_type.
Note: Do not do this in production.
- Test the connection. If the connection is successful, you should see the screen below.
- Next configure Email. The example below is a representative sample where I chose Sendmail.
- Test email.
- Congrats! You have configured Movable Type!
- Configure your account (Administrative Account).
- 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
- Click Finish Install
- 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.
- 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.