25 mei 2009

Using PHP on GAE


Google is now supporting 2 languages for Google App Engine: Phyton and Java. This article shows how you can use PHP on Google App Engine.

Running PHP on GAE is possible by using Quercus from Caucho, Quercus implements PHP in Java, see below URL's about running Quercus on GAE>
Assuming you have a Google App Engine website running with Java enabled and also localy installed the GAE Java SDK and the Google Eclipse plugin.

Assuming also that you did the Java Getting Started tutorial to get hands-on experience with the GAE Java SDK and the Google Eclipse Plugin.

Then you can also get PHP running on GAE with below steps.

1) Create a Google Web Application inside Eclipse

Optional: De-select GWT on the "New Web Application project" wizzard.

2) Copy resin.jar from Resin 4.0 to WEB-INF/lib

Add resin.jar to the java build path: Right-click on the project-name, select 'properties' then 'Java build path' and the add resin.jar under 'Libraries'

3) Modify war/WEB-INF/web.xml so that it contains (also) below content
<welcome-file-list>
<welcome-file>index.php</welcome-file>
</welcome-file-list>

<servlet>
<servlet-name>quercus</servlet-name>
<servlet-class>com.caucho.quercus.servlet.GoogleQuercusServlet<servlet-class>
</servlet>

<servlet-mapping>
<url-pattern>*.php</url-pattern>
<servlet-name>quercus</servlet-name>
</servlet-mapping>
4) Add below lines to war/WEB-INF/appengine-web.xml
<static-files>
<exclude path="/**.php" />
</static-files>

<resource-files>
<include path="/**.php" />
</resource-files>
5) Create the war/index.php file.
<?php 

phpinfo();

?>
6) Run the development server.

7) Surf to: http://localhost:8080/

3 reacties:

aichholzer zei

Why don't you post a detailed description on how to get to run your PHP code on appengine, I've been reading blogs for hours and no one really explains how to get it to work, all describe the magic 4 steps only, which of course don't work.

Thank you

Herbert Groot Jebbink zei

aichholzer: If you have a concrete question I would be glad to help you. However I don't think I must duplicate what Google has done. The Google documentation is very good.

That's why I did wrote below line in this blog posting:

"Assuming also that you did the Java Getting Started tutorial to get hands-on experience with the GAE Java SDK and the Google Eclipse Plugin."

Anoniem zei

I am unable to upload because the resin.jar is too big. thoughts?

Een reactie plaatsen