How to deploy a PHP project in a Tomcat installation

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.