- Don't forget to Install and configure PHP on your machine or it won't work at all - duh!;
- From the JavaBridge Project add JavaBridge.jar, php-script.jar and php-servlet.jar to to the <tomcat home>/lib folder. (Do not be tempted to placed them in the ext folder as it will not work).
- Edit the <tomcat-home>/conf/web.xml file as follows:
<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>
And at the end of the file:
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>index.php</welcome-file>
</welcome-file-list>
- Create a new Tomcat project;
- Add a index.php file with this contents:
<?php phpinfo();?>
- Start the server up and browse to it.
Thursday, 26 January 2012
PHP running in Tomcat
It is fun to have PHP running in Tomcat and not too hard to achieve. Especially if you follow the instructions at PHP/Java Bridge or even here.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment