Skip to content

Deploying WordPress with Quercus

January 12, 2015

Quercus is a PHP implementation written in Java. By using it, you can even deploy WordPress on a Java EE web application server, but its author Caucho Technology provides little information about how to do it. This post tries to provide the missing information for new users.

Getting Quercus and WordPress

First, you must get the archives of Quercus and WordPress. For WordPress, just download it from its home site. (The author fails to run WordPress 4.0 with Quercus, but YMMV.)

To get Quercus, download a WAR archive from its home site, but to deploy WordPress with it, you must extract a JAR archive of Quercus from the WAR. Since a WAR archive has the same internal structure with ZIP, you can any unzip tool to extract files from it. What you need is quercus.jar and should be found in the WEB-INF/lib directory in the WAR archive.

You will also need a MySQL JDBC driver, but this post does not describe how to install the driver to your web application server.

Constructing a web application

If you have got Quercus and WordPress, you can now construct a web application for WordPress. If you extract files the WordPress archive, you will see all files are contained in a directory named wordpress. Just copy all the files and subdirectories in the wordpress directory to the web application root directory, not the directory itself.

Then, create the (WEB-INF and) WEB-INF/lib directory at the web application root, and place quercus.jar there.

Finally, create the WEB-INF/web.xml file.  The minimum file content will be something like the following:

<web-app>
  <servlet>
    <servlet-name>Quercus Servlet</servlet-name>
    <servlet-class>com.caucho.quercus.servlet.QuercusServlet</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>Quercus Servlet</servlet-name>
    <url-pattern>*.php</url-pattern>
  </servlet-mapping>
  <welcome-file-list>
    <welcome-file>index.php</welcome-file>
  </welcome-file-list>
</web-app>

Configuring WordPress

If you have constructed a web application, you can configure WordPress. Copy wp-config-sample.php to wp-config.php and edit it as necessary. If you need any php.ini setting, create the WEB-INF/php.ini file.

If you would like to use a JNDI DataSource by the Quercus’s database parameter, make sure your MySQL JDBC driver uses the ISO8859_1 encoding to suppress character encoding conversion in the driver. Otherwise, all non-ASCII characters might not be displayed correctly. This is because Java assumes Unicode strings while PHP assumes multibyte-encoded ones, and because WordPress assumes the encoding conversion will take place on the MySQL server. By specifying ISO8859_1 as the character encoding, the driver will mostly pass through PHP strings to/from the server where conversion is executed.

Enabling Permalinks

The steps described above should make WordPress run on a Java EE web application server, but pretty permalinks will not work without further configuration. Any configuration for WordPress on PHP (mostly) will not work as your WordPress is on a Java web application server. If you want pretty permalinks, take a look at Pretty Permalink Filter as an additional configuration option. It was written exactly in order to make pretty permalinks work with WordPress on a Java EE web application server.

Advertisements

From → Java

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: