Run PHP on the Google App Engine

Google Appengine Running PHP

Google launched their Google App Engine (GAE) a year ago. The free hosting in App Engine is allocated 500 MB of persistent storage and enough CPU and bandwidth for about 5 million page views a month. Also, if you really want more you can see pricing plans.

GAE will support Java going forward. Unfortunately PHP support on the App Engine is still left as the top item in the wishlist. So until Google announces their official PHP support we have a workaround to run PHP using Quercus. Quercus is basically a 100% Java implementation of the PHP language (requires JDK 1.5).  Since the App Engine now supports Java this means we can use Quercus to run PHP scripts on the App Engine.

So all you need to use the GAE and run PHP
1) Register a free account.
2) Download this file to your computer.
3) Edit application XML tag in the file war\WEB-INF\appengine-web.xml to the name of the application you have registered.
4) Finally upload your application. I downloaded Google App Engine SDK for Java and use the following command in windows.
appcfg.cmd update C:\projects\phpwithjava\war

To see this in action just visit: and

NOTE: phpwithjava is my app name with GAE. Image by Aral Balkan.

Also read...


  1. Unreality said on :

    anyway for the php to access any kind of database. – I know that Memcached is provided by GAE so we can use that by simply adding a key value pair.

  2. Chris said on :


    Thanks for this post.

  3. Strolling on web said on :

    Google App Engine’s datastore has a SQL-like syntax called “GQL”. Select statements in GQL can be performed on one table only. GQL intentionally does not support the Join statement, because it is seen to be inefficient when queries span more than one machine. Instead, one-to-many and many-to-many relationships can be accomplished using ReferenceProperty().This shared-nothing approach allows disks to fail without the system failing.
    The where clause of select statements can perform >, >=, <, <= operations on one column only. Therefore, only simple where clauses can be constructed. Switching from a relational database to the Datastore requires a paradigm shift for developers when modeling their data.
    App Engine limits the maximum rows returned from an entity get to 1000 rows per Datastore call. Most web database applications use paging and caching, and hence do not require this much data at once, so this is a non-issue in most scenarios.[citation needed] If an application needs more than 1,000 records per operation, it can use its own client-side software or an Ajax page to perform an operation on an unlimited number of rows.
    Unlike a relational database such as Oracle, Microsoft SQL Server, MySQL, or PostgreSQL, the Datastore API is not relational in the SQL sense.

  4. Pingback: You can run PHP on Google App Engine | Lacisoft's

  5. Charles Alves said on :

    I run your example. It works fine, thanks. But what about apache url rewriting. Is there any way to implement this?


  6. Pingback: Aral Balkan - How to run PHP on Google App Engine

  7. jQuery Howto said on :

    I was wondering if this is possible… It seems it is 🙂

    @Unreality, Still, you are getting PHP on App Engine! It’s better then nothing… For those developers that don’t want to learn the whole new language this will do for now… 🙂

    PS. They can get another free hosting you might argue 🙂

  8. Ozh said on :

    Interesting. Any ideas about performance on PHP via Java?

  9. mkv said on :

    Java-compiled PHP performance seems to faster than standard PHP (at least PHP without any accelerators). One must understand that querqus is NOT interpreting PHP but compiling PHP to Java classes that will be run at servlet speeds. Moreover, one gets the benefit of using more advanced PHP techniques that further speed up things.

  10. Arto Liukkonen said on :

    Nice post, just had one problem that I got fixed with few tries. When editing war\WEB-INF\appengine-web.xml for application name, notice that application name MUST be in lowercase. For example I created application called “Feedlar”, but if I tried to upload that it hit me with “No permission”. When changed xml config to “feedlar”, it worked like charm.

    Tried to get php-txt-db work with no luck (getting only error 500). Maybe we just have to wait for official php support to get everything work, but for now Appengine can be used as free hosting for simple php applications that doesn’t require database.

  11. Pingback: Google App Engine si PHP | My Binary Life

  12. diablonhn said on :

    Quercus’ pretty fast. Here’s a whitepaper on its performance:

    The open source Quercus version runs in interpreted mode. As far as I can tell, interpreted mode is 10-20% slower than compiled mode. Nevertheless, it’s still faster than regular PHP.

  13. Dafei said on :

    Good job….

  14. taviroquai said on :

    With Java everything is possible…

    Maybe this is why GAE administration has left PHP support aside from the beginning… This is a way to “impose” Java to the developers community besides Python.

  15. Gan said on :

    Good! Will try it later.

  16. Howard said on :


    Your method works well if my php is in the root directory, e.g. under war

    If I create sub folder, then the php file will be downloaded instead.

    Any other method? Looking for a solution from someone


  17. Manuel Arwed Schmidt said on :

    There was a misconfiguration in the first posted apps, you must edit appegine-web.xml in /war/WEB-INF/ so something like this:

    I’m not good at regular expressions, so I’ve cheated a little bit. You’ll see when looking the XML.

    – Arwed

  18. Edmar said on :

    How can I use the datastore api inside PHP ?

  19. blkk said on :

    How about mod_rewrite?

  20. Pingback: Caucho Technology » Blog Archive » Quercus on the Google App Engine

  21. Tuan Nguyen said on :

    Dear All,

    Can anyone tell me: how is about data layer on GAE? As far as I know Google uses persistence objects ( DataNucleus Access Platform) So how do you use the platorm in PHP code?

    Please advise me

  22. Ruggero S said on :

    Very interesting post…will try it tomorrow…

  23. Pingback: » PHP con Google App Engine

  24. Gampesh said on :

    Can we use jsp in Quercus … how can we handle data base operation using java php under quercus please give us example.


  25. Gampesh said on :

    Actually i wanted to make a google app engine application in php using Quercus but how can i do in jsp that i don’t know, the example you have given is not dealing with database connection, so could you please explain how can we make GAE app in php+java with Quercus support which also deal with database (JDO).


  26. Herbert Groot Jebbink said on :

    Hi, I have started a blog about running PHP on Google App Engine,

  27. Tommy Tam said on :

    Has anyone else run into the problem of number of files >1000 exceeding the quota? With PHP, you can easily have more files because you might include some libraries. I found that I can’t port an existing application to GAE because of the 1000 file limit. Any suggestion?

  28. Stefan said on :

    Hey, please advice, I can’t get this work. What folder do I have to upload and at what level in my application?, do I have to upload the entire “phpwithjava” folder in the root of my application?, just the “war” folder or just the “Web-inf” folder.

    My app is called publicame, inside (at root level) I have the .py and .yaml files.

    Any help is much appreciated.

  29. Caucho Blog said on :

    How to install WordPress on Google App Engine:

  30. Herbert Groot Jebbink said on :

    @Stefan, if you have .py and .yaml files then you are working with the Python version of GAE. For PHP you need the java version of GAE. Do the Java Getting Started tutorial and then it is clear where to put the files to get PHP running.

  31. Stefan said on :

    @Herbert Groot Jebbink, thanks man, but why isn’t this described at the very start of this post?

  32. TaoGOGO said on :

    but!!!!! it seems that no one know how to use the database api!!!!!is anyone can tell us?if i can only read by php,i don’t think it’s useful than using jsp or python~

  33. John said on :

    good job 🙂

  34. Pingback: PHP, Web and IT stuff » Blog Archive » Get your own cloud server running in 15 minutes

  35. Gabe Wong said on :

    JIQL, the JDBC Wrapper for Google DataStore, integrates with Quercus.
    So you can run PHP applications with your same SQL queries.

  36. Rubel said on :

    Does anybody know how to access database with php or is there any documentation.

  37. ram said on :

    If I have a legacy php5 application developed, how much modifications required to make it work inside google app engine.

    is app engine for developing new apps or existing projects also ?


  38. Rouletta-Bertram said on :

    Damn, that sound’s so easy if you think about it.

  39. John Gareth said on :

    Sorted, Thanks.

  40. Dean Jerpseth said on :

    Thanks for your insights.

  41. Sander Rietveld said on :

    Thanks 🙂

  42. antyfreeman said on :

    Got it! Thank you.

  43. JOYCE SMITH said on :

    nice job, many thanks.

  44. Robert Snead said on :

    Done. Next step is to setup the database also.

  45. Timothy Nimmons said on :

    I just added my new google app. thanks for the details.

  46. Good Sam said on :

    fantastic.. So much for only python and java support.

  47. ANDY MOATS said on :

    Great work. Thanks for sharing.

  48. Prakash said on :

    Thanks a million!!!!

  49. Anna said on :

    Hey Prakash,
    it seems like you got it, can you please help me install my app on GAE? anyhelp will be great, it#s an opensource rss php reader. Thanks in advance

  50. Atila said on :

    This works for ALL PHP scripts I have tried. Please try this on PHP5. I have not tested it.

  51. Wong said on :

    Thanks a lot !

  52. markus aurelius said on :

    great job putting this info together, works a treat, cheers!

  53. gustavo c said on :

    Nice post, I share my experience with Ubuntu Linux.
    I changed: appcfg.cmd update C:\projects\phpwithjava\war
    for : update my_path/phpwithjava/war
    Thank you very much.

  54. Madhu said on :

    As given in the one of the post- If an application needs more than 1,000 records per operation, it can use its own client-side software or an Ajax page to perform an operation on an unlimited number of rows.

  55. film42 said on :

    It seems a lot of php functions result in 500 server error. Anyone have ideas on opening the library a bit more?

  56. Seenu said on :

    Hi thanks a lot for this… I also managed to run CURL on GAE with this!

  57. Diana said on :

    I managed to run and get almost everything working quickly.
    @ Seenu – Can you please tell me how you got CURL running?

  58. Marko said on :

    Yeah, please do tell how to use curl with Quercus/PHP 🙂 Thanks!

  59. Niki said on :

    Yes, tell me also!

  60. Niki said on :

    OK, that seems to be a joke 🙂 I have read all the Google info and found nothing…

  61. Marion Janet said on :

    Yes @Nikki is right. @Seenu you have to share the curl code to prove yourself right! 😉

    Please plzzz share the curl code ……………..

  62. Ango Yang said on :

    I want run wordpress on GAE

  63. Kegan Jones said on :

    Saw your site bookmarked on Reddit. I love your blog contents. Your site has been very useful for me.

  64. Marion said on :

    it is good and works for me.

  65. conan said on :

    i don’t get it….

    do u mean change the contents inside the “appengine-web.xml” file?

    if so, where do i change(let’s say my application is ‘good’) ?


  66. Sandeep said on :

    Has anyone got CURL working on GAE?

  67. Digisha Modi said on :

    Thanks for sharing this information….

  68. Digisha Modi said on :

    Thanks for sharing this information…

  69. Marcus said on :

    Hey, I’m trying this out, and I am getting the error: “com.caucho.quercus.QuercusModuleException: java.lang.NoClassDefFoundError: is a restricted class. Please see the Google App Engine developer’s guide for more details.”

    I’m using the Facebook API, and it seems to be the connecting to Facebook that is killing it.
    A simple PHP script will working.
    Is there any way to fix this?

Comments are closed.