1. Download Quercus:
http://quercus.caucho.com/
Version of course the best of the latest, because in principle, the new version of PHP support is higher, but in their own testing when the latest 4.0.25 have a problem, and then swap 4.0.18 version.
Select a file download in the war format and use WinRAR decompression to copy the Web-inf\lib\ jar to the war\web-inf\lib\ directory under Gae project
2. Configure Quercus:
Configure support for PHP files in Appengine-web.xml:
<static-files>
- <exclude path= "/**.php"/>
- </static-files>
- <resource-files>
- <include path= "/**.php"/>
- </resource-files>
Add a servlet to the Web.xml:
<servlet>
- <servlet-name>quercus servlet</servlet-name>
- <servlet-class>com.caucho.quercus.servlet.GoogleQuercusServlet</servlet-class>
- </servlet>
To add a mapping to a PHP file:
<servlet-mapping>
- <servlet-name>quercus servlet</servlet-name>
- <url-pattern>*.php</url-pattern>
- </servlet-mapping>
3. Implement URL rewriting (implemented by Urlrewritefilter):
Download the Urlrewritefilter and copy the Urlrewritefilter-*.jar to the War\web-inf\lib\ directory of the Project
Add URL filter to Web.xml
<filter>
- <filter-name>UrlRewriteFilter</filter-name>
- <filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class>
- </filter>
- <filter-mapping>
- <filter-name>UrlRewriteFilter</filter-name>
- <url-pattern>/*</url-pattern>
- <dispatcher>REQUEST</dispatcher>
- <dispatcher>FORWARD</dispatcher>
- </filter-mapping>
Create a new URL rewrite configuration file in the War\web-inf directory of the project: Urlrewrite.xml
<?xml version= "1.0" encoding= "Utf-8"?>
- <! DOCTYPE urlrewrite Public "-//tuckey.org//dtd urlrewrite 4.0//en"
- "Http://www.tuckey.org/res/dtds/urlrewrite4.0.dtd" >
- <urlrewrite>
- <rule enabled= "true" match-type= "regex" >
- <note>UrlRewrite</note>
- <condition type= "Request-filename" operator= "Notfile" name= "Notfile" next= "and"/>
- <condition type= "Request-filename" operator= "Notdir" name= "Notdir" next= "and"/>
- <from>/(. *) </from>
- <to last= "true" type= "forward" >/index.php</to>
- </rule>
- </urlrewrite>
This rule is equivalent to the one in. htaccess:
Rewritecond%{script_filename}!-f
Rewritecond%{script_filename}!-d
Rewriterule ^ (. *) $ index.php/$1
Note: This rule may cause gae local admin http://localhost:8888/_ah/admin/to fail because the time relationship is no longer fixed.
4. Test:
Create a new index.php file in the War\ directory of the project:
<?php
- Echo ' <pre> ';
- Print_r ($_server);
- ?>
Because I have set index.php to welcome file, I open the http://localhost:8888/directly
The effect is as shown in the figure:
Some reference materials are attached:
http://blog.caucho.com/2009/04/28/quercus-on-the-google-app-engine/
http://blog.caucho.com/2009/05/31/quercus-on-google-app-engine/
http://tuckey.org/urlrewrite/#documentation
Phper are still hesitating, hurry up!