首页 > php教程 > php手册 > 正文

在GAE上搭建PHP环境并开启URL重写

WBOY
发布: 2016-06-21 08:51:25
原创
1060 人浏览过

1.下载quercus:

http://quercus.caucho.com/

版本当然最新的最好,因为原则上来说新版本对php支援程度更高,但是在自己测试的时候发现最新的4.0.25存在一点问题,于是换用4.0.18版本.

选择WAR格式的文件下载,利用Winrar解压,将WEB-INF\lib\的jar拷贝至GAE工程下的war\WEB-INF\lib\目录

2.配置Quercus:

在appengine-web.xml中配置对php文件的支持:

登录后复制
登录后复制
登录后复制
登录后复制
  1. 		<span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; border-image: initial; color: black; background-color: inherit; "><span class="tag" style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 7px; padding-right: 0px; padding-bottom: 4px; padding-left: 0px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; border-image: initial; color: rgb(0, 102, 153); background-color: inherit; width: 635px; font-weight: bold; "><span class="tag-name" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; border-image: initial; color: rgb(0, 102, 153); background-color: inherit; font-weight: bold; ">static-files</span><span class="tag" style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 7px; padding-right: 0px; padding-bottom: 4px; padding-left: 0px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; border-image: initial; color: rgb(0, 102, 153); background-color: inherit; width: 635px; font-weight: bold; ">></span><span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; border-image: initial; background-color: inherit; "> </span></span></span>
    登录后复制
  2.     exclude path="/**.php" /> 
  3. static-files> 
  4. resource-files> 
  5.     include path="/**.php" /> 
  6. resource-files> 

在web.xml中添加一个servlet:

登录后复制
登录后复制
登录后复制
登录后复制
  1. 		<span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; border-image: initial; color: black; background-color: inherit; "><span class="tag" style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 7px; padding-right: 0px; padding-bottom: 4px; padding-left: 0px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; border-image: initial; color: rgb(0, 102, 153); background-color: inherit; width: 635px; font-weight: bold; "><span class="tag-name" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; border-image: initial; color: rgb(0, 102, 153); background-color: inherit; font-weight: bold; ">servlet</span><span class="tag" style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 7px; padding-right: 0px; padding-bottom: 4px; padding-left: 0px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; border-image: initial; color: rgb(0, 102, 153); background-color: inherit; width: 635px; font-weight: bold; ">></span><span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; border-image: initial; background-color: inherit; "> </span></span></span>
    登录后复制
  2.     servlet-name>Quercus Servletservlet-name> 
  3.     servlet-class>com.caucho.quercus.servlet.GoogleQuercusServletservlet-class> 
  4. servlet> 

添加对php文件的映射:

登录后复制
登录后复制
登录后复制
登录后复制
  1. 		<span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; border-image: initial; color: black; background-color: inherit; "><span class="tag" style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 7px; padding-right: 0px; padding-bottom: 4px; padding-left: 0px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; border-image: initial; color: rgb(0, 102, 153); background-color: inherit; width: 635px; font-weight: bold; "><span class="tag-name" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; border-image: initial; color: rgb(0, 102, 153); background-color: inherit; font-weight: bold; ">servlet-mapping</span><span class="tag" style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 7px; padding-right: 0px; padding-bottom: 4px; padding-left: 0px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; border-image: initial; color: rgb(0, 102, 153); background-color: inherit; width: 635px; font-weight: bold; ">></span><span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; border-image: initial; background-color: inherit; "> </span></span></span>
    登录后复制
  2.     servlet-name>Quercus Servletservlet-name> 
  3.     url-pattern>*.phpurl-pattern> 
  4. servlet-mapping> 

3.实现URL重写(通过UrlRewriteFilter实现):

下载UrlRewriteFilter,将urlrewritefilter-*.jar拷贝在工程的war\WEB-INF\lib\目录下

在web.xml中添加URL过滤

登录后复制
登录后复制
登录后复制
登录后复制
  1. 		<span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; border-image: initial; color: black; background-color: inherit; "><span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; border-image: initial; background-color: inherit; "> </span><span class="tag" style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 7px; padding-right: 0px; padding-bottom: 4px; padding-left: 0px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; border-image: initial; color: rgb(0, 102, 153); background-color: inherit; width: 635px; font-weight: bold; "><span class="tag-name" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; border-image: initial; color: rgb(0, 102, 153); background-color: inherit; font-weight: bold; ">filter</span><span class="tag" style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 7px; padding-right: 0px; padding-bottom: 4px; padding-left: 0px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; border-image: initial; color: rgb(0, 102, 153); background-color: inherit; width: 635px; font-weight: bold; ">></span><span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; border-image: initial; background-color: inherit; "> </span></span></span>
    登录后复制
相关标签:
来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门推荐
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板