Java developers know that Tomcat is used to deploy Java Web projects. A few days ago, the old K accidentally learned that Php/java Bridge, through it can be implemented between the JSP and PHP sharing session, see "How to implement JSP and PHP sharing Session" PHP tutorial, today whim, through Php/java Bridge can be able to deploy a fully PHP-developed project into Tomcat, although not very significant, but for those who need to integrate PHP development in the Java project is still useful. Say dry, I immediately go to Php/java Bridge's official website to see, originally it can also be used to deploy PHP project to the use of Tomcat, the official mention can be Moodle, MediaWiki, Joomla and other PHP open source projects deployed to Tomcat. Here are the detailed steps.
1. Environmental preparedness
The deployment of PHP project to Tomcat does not mean that you do not need to install PHP, in fact, it is necessary to install PHP environment, the old K installed is xampp, so it is convenient to install the PHP environment, XAMPP installation tutorial Please refer to "How to install XAMPP" The Java Virtual machine and Tomcat need to be installed in addition to PHP. The minimum configuration for these tools is PHP 5.x, Java 6 or above, Tomcat 6 or higher.
2. Configure Tomcat
Copy the Javabridge.jar, Php-servlet.jar, and Php-script.jar of the Php/java Bridge into the Tomcat Lib directory;
Modify the Web. xml file in the Conf folder under the Tomcat installation directory and add the following code to the Web-app tag;
123456789101112131415161718192021222324252627 |
<
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
>
|
Then add the following line of code to the welcome-file-list tag
1 |
< welcome-file >index.php</ welcome-file > |
3. Deploying PHP Projects
Go directly to the PHP project and copy it to Tomcat's WebApps directory, then launch Tomcat, and in the browser enter "http://localhost:8080/php project name" to see the effect.