开发者

How can i run Single PHP File using apache-tomcat-6.0.18?

开发者 https://www.devze.com 2022-12-26 09:46 出处:网络
i want to run single php file using apache-tomcat-6.0.18 my project is GWT project with server side is java servlet

i want to run single php file using apache-tomcat-6.0.18

my project is GWT project with server side is java servlet

i deployed my project on server in ap开发者_运维百科ache-tomcat-6.0.18/webapps/ folder

So please tell me the solution to run php file


We can do this by using JavaBridge..

Download below jar file (ie extract jars from JavaBridge.war)

JavaBridge.jar
php-script.jar
php-servlet.jar

and put into your project lib folder. then type the following entry in 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>

save the file. Restart tomcat server. now Php files will be work under tomcat server!


"www" folder is present in IIS server not in apache ... In apache tomcat server instead of "www" , "Root" folder is present copy all those needed files in that root folder and have acces to thos files

after installation of any server a single restart is mandatory ,, otherwise results are unpredictable... Thanks a lot


Use the PHP/Java Bridge. As long as your PHP was compiled with cgi support, it should work seamlessly.


Quercus has a war that allows to run PHP scripts in apache tomcat or glassfish. For a step by step guide look at this article


You should put your php file in www folder in apache installation and then you can access that file from browser like this:

http://localhost/your_file_name.php

localhost is the default host name in most configurations.

0

精彩评论

暂无评论...
验证码 换一张
取 消