Deploying PHP Applications on CloudBees

Written by: Nicolas De Loof

CloudBees focus on being the bleeding edge PaaS for Java, but please remember "Java" is used here as the name of the virtual machine, not the language. The JVM is able to host a large set of languages, including some unexpected ones like PHP!

Quercus is a PHP emulation / compiler for the JVM, that will bring Java power and facilities to PHP developers. Thanks to Java platform they can benefit enhanced performance (with the adequate compiler license), server features like session clustering and connection pooling, or even integrate with Java libraries and services.

I just setup a proof of concept deployment for a PHP application. I choose phpBB to get something more significant than just a simple HelloWorld.

First step is naturally to setup a repository for code. I've used github so that you can browse this sample project . Quercus is distributed as a war archive, I just expanded it at repository root so that I just can add PHP files like I'd do for an old-school FTP deployment on my favorite LAMP hosting.

I've added the adequate cloudbees-web.xml, so that my application can be deployed on RUN@cloud and access my MySQL database :

<cloudbees-web-app>  <appid>nicolas/quercus</appid> </cloudbees-web-app> 

With a single line configuration in web.xml, Quercus will automagically redirects all mysql_connect() calls to my JDBC datasource, so that RUN@cloud connection pool will be used under the hood.

A simple Ant build script is used to assemble the war archive for deployment :

<project basedir="." default name="quercus-cloudbees">  <description> deploying a php app on cloudbees 
             </description> <target name="war"><war basedir="${basedir}" br="" destfile="build/application.war">excludes="build/**/*" /></war> </target> 
</project> 

I've also created a Jenkins job on DEV@cloud and used the CloudBees deployer plugin to push the application on RUN@cloud as a continuous deployment process. You can see the application running at http://quercus.nicolas.cloudbees.net/

Note : by default, phpBB is using a configuration file stored on local file system, that will not be persisted as RUN@cloud is dynamically assigning physical resources, so I had to hack a preconfigured config.php script.

Stay up to date

We'll never share your email address and you can opt out at any time, we promise.