原文链接:http://www.blogjava.net/freeman1984/archive/2011/06/16/352427.html
环境:
操作系统:IBM aix5.3(当然linux环境和windows下肯定是没问题的)
1 运行php当然首选apache这里就不讲apache方式了,可见于http://www.blogjava.net/freeman1984/archive/2011/06/10/352043.html,但是在aix下php和apache的结合始终没有装好,linux下我试过一点问题没有。有成功的案例可以给个链接看看,谢谢!
下面介绍两种单独使用tomcat运行php的:
-------------------------------------------------------------------------------------------
1 使用tomcat内置的cgi支持(需要安装php环境,去官网下载就行了http://www.php.net/downloads.php,要注意的是,我在aix上5.X装不上,用4.X的没问题)
1 :Rename $CATALINA_BASE/server/lib/servlets-cgi.renametojar
$CATALINA_BASE/server/lib/servlets-cgi.jar
.
2.Remove the XML comments from around the CGI servlet and servlet-mapping configuration in $CATALINA_BASE/conf/web.xml
.(也就是添加cgi的servlet支持,打开注释即可)
还有后面的mapping
3 添加several servlet init parameters which can be used to configure the behaviour of the CGI servlet(添加几个servlet的参数)
- cgiPathPrefix
- The CGI search path will start at the web application root directory + File.separator + this prefix. The default cgiPathPrefix is WEB-INF/cgi(php文件放置的位置)
- debug
- Debugging detail level for messages logged by this servlet. Default 0. - executable
- The of the executable to be used to run the script. Default is perl
.(添加解析php的引擎) - parameterEncoding
- Name of the parameter encoding to be used with the GCI servlet. Default is System.getProperty("file.encoding","UTF-8")
. - passShellEnvironment
- Should the shell environment variables (if any) be passed to the CGI script? Default is false
.
tomcat6.X下面没有第一步。
4,测试,添加一个web应用,这里使用ROOT即可,编写一个index.php放到webapps/ROOT/WEB-INF/cgi/下面内容:
启动tomcat,访问http://localhost:8080/cgi-bin/index.php即可。
---------------------------------------------------------------------------------
另外一种方式是使用quercus:
1 我们把php项目当做一个web项目放在webapps下,并在里面建WEB-INF\lib目录
2
3 启动tomcat,
4 像访问j2ee web应用一样访问php应用即可。我们现在aix生产环境用的就是这种,比较稳定。
其他方式兄弟们可以扩充。