我想用Apache的Tomcat的6.0.18我如何使用apache-tomcat-6.0.18運行單個PHP文件?
運行單一的PHP文件我的項目是與服務器端的GWT項目是Java Servlet的
我部署我的項目上服務器Apache的Tomcat的6.0.18/webapps /目錄文件夾
所以,請告訴我該解決方案來運行PHP文件
我想用Apache的Tomcat的6.0.18我如何使用apache-tomcat-6.0.18運行單個PHP文件?
運行單一的PHP文件我的項目是與服務器端的GWT項目是Java Servlet的
我部署我的項目上服務器Apache的Tomcat的6.0.18/webapps /目錄文件夾
所以,請告訴我該解決方案來運行PHP文件
你應該把你的PHP文件在Apache安裝www
文件夾,然後你可以從瀏覽器訪問該文件是這樣的:
http://localhost/your_file_name.php
localhost
是大多數配置中的默認主機名。
Use the PHP/Java Bridge。只要你的PHP是用cgi支持編譯的,它應該可以無縫工作。
我們可以通過使用爲JavaBridge ..下面的jar文件
下載做到這一點(即從JavaBridge.war提取罐)
JavaBridge.jar
php-script.jar
php-servlet.jar
,並把你的項目lib文件夾。然後在web.xml中
的web.xml
<!-- the following 8 lines extend the servlet spec 2.2 "url-pattern" to handle PHP PATH_INFO: *.php/something?what=that. Remove them, if you don't need this feature. -->
<filter>
<filter-name>PhpCGIFilter</filter-name>
<filter-class>php.java.servlet.PhpCGIFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>PhpCGIFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- the following adds the JSR223 listener. Remove it if you don't want to use the JSR223 API -->
<listener>
<listener-class>php.java.servlet.ContextLoaderListener</listener-class>
</listener>
<!-- the back end for external (console, Apache/IIS-) PHP scripts; remove it if you don't need this -->
<servlet>
<servlet-name>PhpJavaServlet</servlet-name>
<servlet-class>php.java.servlet.PhpJavaServlet</servlet-class>
</servlet>
<!-- runs PHP scripts in this web app; remove it if you don't need this -->
<servlet>
<servlet-name>PhpCGIServlet</servlet-name>
<servlet-class>php.java.servlet.fastcgi.FastCGIServlet</servlet-class>
<load-on-startup>0</load-on-startup>
</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>
保存文件以下條目。重新啓動tomcat服務器。現在PHP文件將在tomcat服務器下工作!
「www」的文件夾中存在不阿帕奇... 在Apache Tomcat服務器,而不是「WWW」 IIS服務器,「根」文件夾中存在 複製所有需要的文件在根文件夾,並有存取權限茨艾倫文件
安裝任何服務器的單個重啓是強制性的後,,否則結果難以預料...... 非常感謝
Tomcat設計用於運行servlet,它處理自己對HTTP請求的響應。 PHP被設計成一個預處理程序,與一個完整的Web服務器(如處理請求本身的Apache)一起運行。 – Amber 2010-04-13 08:53:59
同意Dav。你在混合東西。它可以從Java內部運行PHP(如下面的文章中所解釋的),但是你想遠離它。無論是運行java servlets還是完全運行PHP,如http://code.google.com/p/gwtphp/中所述,如果您絕對需要GWT。但不要混用技術,這是不值得的。 – 2010-04-13 10:38:48