Running Quercus PHP on App Engine

Here are the steps I took to get PHP running on Google App Engine.

Since PHP is not supported by GAE as of this writing, we need to run it on the Java platform that is supported.

Fortunately, there’s a PHP 5 implementation in Java that let’s us do just that. The thing is called Quercus PHP and is developed by Caucho.

Here’s a good reference document for the first few steps that involve setting up your local box with GAE Java SDK:

1. Get Java 6, more precisely Java SE Development Kit 6. According to Google you can use Java 5 for Macs ( While the JDK installs itself, move on to the next step.

2. Get Eclipse IDE for Java EE Developers.

3. Get Google App Engine plugin for Eclipse. Again, Google has a nice page that describes the process in greater detail: – see Installing the Google Plugin for Eclipse section. One note, once you get to the License Agreements screen, just click on Finish. The Next button will remain grayed out no matter what.

I then followed the instructions under Creating a Project on this page:

Once I got the Guestbook example to work it was time to get the Quercus PHP to work. Here’s a reference from the Quercus creators: and another useful page is here:

This is what I did:

  1. Downloaded the latest Resin application server: I used open source version.
  2. Unzipped the file.
  3. Went to the unzipped directory, selected lib/resin.jar and copied it to my projects war/WEB-INF/lib folder.
  4. Having the Guestbook example still open, right clicked on the project name, chose  Build Path->Configure Build Path, selected Libraries tab, and then added resin.jar from the ‘war/WEB-INF/lib’ folder by clicking on the Add JARs… button. Clicked OK.
  5. Copied the following to my war/WEB-INF/web.xml file. The existing code can remain there, I just pasted this below. Also, the version from the Caucho’s blog needed some adjustments, so here’s the version that worked for me:
  6. Next, I pasted this to war/WEB-INF/appengine-web.xml – again under the existing code:
          <exclude path="/**.php"/>
          <include path="/**.php"/>

    This is supposedly needed to make sure the .php files get processed by PHP and not served up as text.

  7. Then I added index.php to war/WEB-INF and simply put this in the file:


  8. Selected the project, Guestbook, on the top menu chose Run->Debug As->Web Application
  9. Finally, went to http://localhost:8888/index.php and marveled at the miracle.

5 Comments to “Running Quercus PHP on App Engine”

  1. By kevin, August 16, 2010 @ 12:05 pm

    Great explanation!

    I got this to work on my local machine, but when I upload it to GAE, it says the resin jar is too big.

    Any thoughts?

  2. By Raivo, August 16, 2010 @ 10:05 pm

    Did you try uploading your app from the command line with the –enable_jar_splitting option?

  3. By PHP on Google App Engine, October 29, 2010 @ 1:56 pm

    This helped me when creating a package for easy PHP application building on Google. Thanks!

  4. By Danny, November 4, 2010 @ 10:55 am

    I was trying to deploy a php based application onto Google Appengine with the Quercus php engine.

    the basics worked (phpinfo() etc.) but my application had some trouble with the file_get_contents call which wouldn’t get the file. the error looked something like this:

    create_request.php:35: Warning: ./simplexml.txt cannot be read [file_get_contents]

    I was trying to access a file in the file system local to the script (not an external url).

    I’ve seen a couple of articles hinting at limitations with the php implementation (obviously db support is one thing) but nothing firm on support for file_get_contents or fopen.

    Is there a limitation for local file access? Are there any configuration options that block file access (I’m aware of the allow_url_fopen = On but nothing specific to local files)?

    thanks, Danny

  5. By Raivo, November 4, 2010 @ 8:53 pm

    @Danny: is the file in the war/WEB-INF folder?

    Also, seems like there was a bug with file_get_contents which should be fixed in v4.0.4 so I hope you are using the latest version.

RSS feed for comments on this post. TrackBack URI

Leave a Reply