Running PHP applications in Tomcat 6
来源:互联网 发布:网络剧男演员 编辑:程序博客网 时间:2024/06/05 19:58
Running PHP applications in Tomcat 6
This guide shows how to install and run PHP applications like Moodle, mediaWiki, Joomla as Tomcat 6 web applications. And how to install PHP 5.x for all existing web applications.
Download and install Java, Tomcat and PHP
Use a graphical packet installer to install PHP. Or download JavaBridge.war, which contains an embedded PHP binary.
Download and install Java 6 or above.
Download and install the original tomcat servlet engine.
Install a PHP web application into Tomcat
Copy the PHP web application JavaBridgeTemplate.war or the demo JavaBridge.war to the Tomcat webapps directory.
Wait two seconds until Tomcat has loaded the web application.
Browse to http://127.0.0.1:8080/JavaBridgeTemplate621 and http://127.0.0.1:8080/JavaBridgeTemplate621/test.php to see the PHP info page.
Rename the file file:webapps/JavaBridgeTemplate621 directory, for example to file:webapps/Moodle, and download and install your PHP application to this directory.
Browse to the name of your web application, for example http://127.0.0.1:8080/Moodle, to run it from your internet browser.
PHP support for all existing Tomcat web applications
If you want to enable PHP for all of your web applications, move the Java libraries from the local web application folder to the Tomcat library folder and edit the Tomcat web configuration as follows:
Stop Tomcat.
Move the libraries JavaBridge.jar, php-servlet.jar and php-script.jar from the webapps/JavaBridgeTemplate621/WEB-INF/lib directory over to the tomcat lib directory.
Edit the Tomcat conf/web.xml. Add the following 9 lines marked with a +:
<web-app xmlns=... >
+ <listener><listener-class>php.java.servlet.ContextLoaderListener</listener-class></listener>
+ <servlet><servlet-name>PhpJavaServlet</servlet-name><servlet-class>php.java.servlet.PhpJavaServlet</servlet-class>
+ </servlet>
+ <servlet><servlet-name>PhpCGIServlet</servlet-name><servlet-class>php.java.servlet.fastcgi.FastCGIServlet</servlet-class>
+ <init-param><param-name>prefer_system_php_exec</param-name><param-value>On</param-value></init-param>
+ <init-param><param-name>php_include_java</param-name><param-value>Off</param-value></init-param>
+ </servlet>
+ <servlet-mapping><servlet-name>PhpJavaServlet</servlet-name><url-pattern>*.phpjavabridge</url-pattern> </servlet-mapping>
+ <servlet-mapping><servlet-name>PhpCGIServlet</servlet-name><url-pattern>*.php</url-pattern></servlet-mapping>
...
</web-app>
Start Tomcat again. Now you can add PHP scripts to tomcat.
Add a PHP test file
<?php require_once("java/Java.inc");
echo java("java.lang.System")->getProperties(); ?>
to some web context, for example "examples", and browse to http://yourHost.com:8080/examples/test.php.
Check the process list using the Unix/Linux or Windows task manager. There should be 5 php-cgi FastCGI executables waiting for requests from Java.
This guide shows how to install and run PHP applications like Moodle, mediaWiki, Joomla as Tomcat 6 web applications. And how to install PHP 5.x for all existing web applications.
Download and install Java, Tomcat and PHP
Use a graphical packet installer to install PHP. Or download JavaBridge.war, which contains an embedded PHP binary.
Download and install Java 6 or above.
Download and install the original tomcat servlet engine.
Install a PHP web application into Tomcat
Copy the PHP web application JavaBridgeTemplate.war or the demo JavaBridge.war to the Tomcat webapps directory.
Wait two seconds until Tomcat has loaded the web application.
Browse to http://127.0.0.1:8080/JavaBridgeTemplate621 and http://127.0.0.1:8080/JavaBridgeTemplate621/test.php to see the PHP info page.
Rename the file file:webapps/JavaBridgeTemplate621 directory, for example to file:webapps/Moodle, and download and install your PHP application to this directory.
Browse to the name of your web application, for example http://127.0.0.1:8080/Moodle, to run it from your internet browser.
PHP support for all existing Tomcat web applications
If you want to enable PHP for all of your web applications, move the Java libraries from the local web application folder to the Tomcat library folder and edit the Tomcat web configuration as follows:
Stop Tomcat.
Move the libraries JavaBridge.jar, php-servlet.jar and php-script.jar from the webapps/JavaBridgeTemplate621/WEB-INF/lib directory over to the tomcat lib directory.
Edit the Tomcat conf/web.xml. Add the following 9 lines marked with a +:
<web-app xmlns=... >
+ <listener><listener-class>php.java.servlet.ContextLoaderListener</listener-class></listener>
+ <servlet><servlet-name>PhpJavaServlet</servlet-name><servlet-class>php.java.servlet.PhpJavaServlet</servlet-class>
+ </servlet>
+ <servlet><servlet-name>PhpCGIServlet</servlet-name><servlet-class>php.java.servlet.fastcgi.FastCGIServlet</servlet-class>
+ <init-param><param-name>prefer_system_php_exec</param-name><param-value>On</param-value></init-param>
+ <init-param><param-name>php_include_java</param-name><param-value>Off</param-value></init-param>
+ </servlet>
+ <servlet-mapping><servlet-name>PhpJavaServlet</servlet-name><url-pattern>*.phpjavabridge</url-pattern> </servlet-mapping>
+ <servlet-mapping><servlet-name>PhpCGIServlet</servlet-name><url-pattern>*.php</url-pattern></servlet-mapping>
...
</web-app>
Start Tomcat again. Now you can add PHP scripts to tomcat.
Add a PHP test file
<?php require_once("java/Java.inc");
echo java("java.lang.System")->getProperties(); ?>
to some web context, for example "examples", and browse to http://yourHost.com:8080/examples/test.php.
Check the process list using the Unix/Linux or Windows task manager. There should be 5 php-cgi FastCGI executables waiting for requests from Java.
Please see our FAQ for more information how to set up a load balancer or how to create a distributable PHP/Java web application.
http://php-java-bridge.sourceforge.net/doc/tomcat6.php
- Running PHP applications in Tomcat 6
- Running system commands in Java applications
- Running system commands in Java applications
- Running ASP.NET 5 applications in Linux Containers with Docker
- Recipes for Running Spark Streaming Applications in Production
- Bypassing HTTP Basic Authentication in PHP Applications
- Breaking Changes for ASP.NET 2.0 applications running in Integrated mode on IIS 7.0
- Error running Tomcat 6: Address localhost:8080 is already in use
- Running PHP cron jobs – regular scheduled tasks in PHP
- Multithreading in .NET Applications
- ANR in Android Applications
- tomcat启动错误:Error running tomcat: Address localhost:1099 is already in use
- Fatal error: Cannot redeclare class Config in /Applications/XAMPP/xamppfiles/lib/php/Config.php on l
- Free Apache Tomcat Hosting in the Cloud for Java Applications? It's Called OpenShift!
- Top 6 Database Performance Metrics to Monitor in Enterprise Applications
- Running neutron in apache2
- Running Nutch in Eclipse
- Running cinder in apache2
- IE7下载时文件名称中包含空格会转化成下划线是什么原因
- "/S60/devices/S60_3rd_FP2_SDK_v1.1/epoc32/" does not exist"
- What is Vmware vCPU ?
- GridView空记录时显示Header和Footer
- Parsing error
- Running PHP applications in Tomcat 6
- C语言:常见错误
- web.xml配置詳解
- nagios+nginx从环境搭建到配置
- 重构第一步
- swap 增加分区大小
- 程序员的目标应该是向牛人看齐而不是当经理或者赚大钱
- windows github帮助文档
- 使用Eclipse集成的CVS客户端下载SourceForge.net的源码