Build PHP environment on Gae and turn on URL rewriting _php tutorial

Source: Internet
Author: User
1. Download Quercus:

http://quercus.caucho.com/

Version of course the latest best, because in principle, the new version of PHP more support, but in their own testing to find the latest 4.0.25 there is a problem, so swap 4.0.18 version.

Select File Download in war format, unzip with winrar, copy web-inflib jar to warweb-inflib directory under Gae project

2. Configure Quercus:

To configure support for PHP files in Appengine-web.xml:

 
 
  1. < Static-files >
  2. < Exclude path="/**.php" />
  3. Static-files >
  4. < Resource-files >
  5. < include path="/**.php" />
  6. Resource-files >

Add a servlet to Web. xml:

 
  
  
  1. < Span class= "Tag-name" >servlet >
  2. < servlet-name > Quercus servlet servlet-name >
  3. < > com.caucho.quercus.servlet.GoogleQuercusServlet span class= "tag" >!-- servlet-class >
  4. !-- servlet >

To add a map to a PHP file:

 
  
  
  1. < servlet-mapping >
  2. < Servlet-name > Quercus Servlet servlet-name >
  3. < Url-pattern > *.php url-pattern >
  4. servlet-mapping >

3. Implement URL rewriting (implemented via Urlrewritefilter):

Download Urlrewritefilter, copy the Urlrewritefilter-*.jar to the Warweb-inflib directory of the Project

Add URL filtering to Web. xml

 
 
  1. <filter >
  2. < Filter-name > Urlrewritefilter filter-name >
  3. < Filter-class > Org.tuckey.web.filters.urlrewrite.UrlRewriteFilter filter-class >
  4. Filter >
  5. < filter-mapping >
  6. < Filter-name > Urlrewritefilter filter-name >
  7. < Url-pattern > /* url-pattern >
  8. < Dispatcher > REQUEST Dispatcher >
  9. < Dispatcher > FORWARD Dispatcher >
  10. filter-mapping >

Create a new URL rewrite profile in the Warweb-inf directory of the project: Urlrewrite.xml

 
 
  1. XML version="1.0" encoding="Utf-8" ?>
  2. "Http://www.tuckey.org/res/dtds/urlrewrite4.0.dtd">
  3. < Urlrewrite >
  4. < Rule enabled="true" match-type="regex" >
  5. < Note > Urlrewrite Note >
  6. < condition type = " request-filename " operator = "notfile" span class= "attribute" >name = "notfile" span class= "attribute" >next = "and" /
  7. < condition type="request-filename" operator="Notdir" name = "Notdir" next = "and "/>
  8. < from > /(.*) From >
  9. < to Last="true" type="forward"> /index.phpto >
  10. Rule >
  11. Urlrewrite >

This rule is equivalent to the. htaccess:

Rewritecond%{script_filename}!-f

Rewritecond%{script_filename}!-d

Rewriterule ^ (. *) $ index.php/$1

Note: This rule may cause the GAE local management http://localhost:8888/_ah/admin/to fail, as the time relationship is no longer corrected.

4. Test:

Create a new index.php file in the project's War directory:

 
  
  
  1. Php
  2. Echo '<pre>
  3. ?>

Since I have set index.php to welcome file, I will open it directly http://localhost:8888/

Effect:

498) this.width=498; ' OnMouseWheel = ' javascript:return big (This) ' src= ' http://www.bkjia.com/uploadfile/2013/0904/ 20130904095435444.png "alt=" \ "style=" margin:0px; padding:0px; border:0px; "/>

Some references 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 what, hurry up ~


http://www.bkjia.com/PHPjc/445669.html www.bkjia.com true http://www.bkjia.com/PHPjc/445669.html techarticle 1. Download the quercus:http://quercus.caucho.com/version of course the latest best, because in principle, the new version of PHP more support, but in their own testing to find the latest 4.0.25 exist ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.