1, preface due to the company's needs, the author needs to build a PHP project, but the author has not contacted any PHP related development, so about PHP basic development knowledge, environment building requirements, as well as compilers do not understand. However, the author found that even if their own integration of the PHP development environment, but also the need for Apache server support, because recently in the development of Java EE often used to tomacat hot deployment projects, naturally think of Tomcat is also Apache products, can you deploy PHP project in Tomcat? After a study, it is feasible to determine. 2, install PHP environment although you can run PHP project in Tomcat, but does not mean not to configure the PHP environment, so the first step is to install the PHP environment. It is now common to use Apache+php+mysql to compose a PHP project that can be installed separately for the development. But I am lazy and not interested in in-depth study of PHP, so using the XAMPP, it can install all the PHP development needs of the environment including the compiler. XAMPP: According to our environment Select download version is good: The download is complete installation, as long as the next step is OK. However, one of the important steps is to choose the environment content of the installation. : Two of them must not be removed, and that PHP is the PHP development environment we want. The rest because the author of the computer itself is installed with MySQL and Tomcat so do not press install. The reader chooses to install according to his own situation. 3. Configuring Tomcat support PHP Project first we need to download the jar package to support the PHP project. : We put the unpacked jar package into the Tomcat Lib directory: Next we need to configure Web. XML, which is in the Tomcat conf directory: We add content to the <web-app> node:
[HTML]View Plain Copy
- <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 find the <welcome-file-list> node and add the following welcome content:
[HTML]View Plain Copy
- <welcome-file>index.php</welcome-file>
At this point, our basic configuration is complete. 4. Add PHP project to Tomcat I'll copy our PHP project in the WebApp directory of Tomcat. I put the Formdesign project here. You can then start the Tomcat server. When it starts, we can enter the address to access the PHP project normally.
Due to the content of the company's privacy, inconvenience upload reprint: http://blog.csdn.net/qq_25722767/article/details/52595498
Configure Tomcat to run the PHP project