An easy and pre-packaged WAR to run WordPress in your preferred Java servlet container (es. Tomcat).
To run a wordpress inside an application server, you need few things:
- Something that can interpret PHP
- An application server
- A MYSQL/MariaDB server
Luckly there’s the more pragmatic Caucho (author of the Resin application server) that give us Quercus, a PHP5 Java implementation with a ready to use Servlet that does all the dirty job. All credits goes to Caucho and Quercus authors!
Look at the update post for version 4.4.1
So what I’ve done here is put all together, test it a bit and try to provide a WAR with all you need inside, and, why not, useful maven artifact for maximum reuse.
MAKE YOUR BLOG WITH A MAVEN WAR OVERLAY
As an example, this could be your POM if you want a blog based on wordpress.
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>io.bonfab</groupId> <artifactId>blog</artifactId> <version>1.0-SNAPSHOT</version> <packaging>war</packaging> <dependencies> <dependency> <groupId>it.bytefox</groupId> <artifactId>jwordpress</artifactId> <version>4.2.2</version> <type>war</type> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>5.1.30</version> <scope>provided</scope> </dependency> </dependencies> <repositories> <repository> <id>bytefox</id> <url>http://maven.bytefox.it/</url> <snapshots><enabled>true</enabled></snapshots> </repository> </repositories> </project>
DOES IT REALLY WORKS?
Well, if you can see this site the answer is: yes! After some tests (and after wordpress 4.1 that caused an infinite call recursion on blog with more than one page) I can say that all seems fine.
You can use the dashboards, change/configure themes, use plugins (jetpack, and code highlighters, as you can see) etc. Almost all the problems that I’ve encountered was fixed upgrading wordpress (so Quercus seems doing his job), except this:
- Automatically install/upgrade themes and plugins from the dashboard: quercus doesn’t fully implement curl (seems a long time bug…) but maybe I can make a workaround for it. Anyway a wget and unzip from ssh does the job without hassle!
- Permalinks: we don’t have here apache mod_rewrite. A filter can solve this, stay tuned.
GIVE ME THE SOURCES
The nerd/geek inside of me would answer: “because we can!”, and that’s a good reason for me. Other than that, this site is hosted on a Linode with 2GB of RAM and other services running on a simple Tomcat.
So why waste other memory with a “full compliant” Apache/PHP runtime, when I can use the already running JVM?
Hoping to not infringe some strange redistribute rights (come’n It’s all open-source here!), I plan to follow WordPress/Quercus releases and upgrade jwordpress, testing it for my use on this blog (with some help of technologies like Ansible… I’ll surely write my 2 cent on this)
The jwordpress version number will follow the wordpress version, with eventually a revision number if needed.
Thanks for reading, and happy blogging with JWordpress!