What should I do if tomcat does not support php?

藏色散人
Release: 2023-03-04 18:52:01
Original
2372 people have browsed it

Solution to the problem that tomcat does not support php: First, copy the relevant files under "PHP/Java Bridge" to tomcat's lib directory; then modify "web.xml" in the conf folder in the tomcat installation directory file; finally restart tomcat.

What should I do if tomcat does not support php?

Recommended: "PHP Video Tutorial"

Java developers all know that tomcat It is used to deploy java web projects. During this period, there was a project that required the same domain name and port as the PHP project. How to achieve this without using nginx? I learned that tomcat can support running php throughJava Bridge.Let’s try it too. YesThe following are the detailed steps.

1. Environment preparation

Installed php environment,installed java virtual machine, tomcat

The minimum configuration of these tools is php 5.x, java 6 or above, tomcat 6 or above.

2. Configure tomcat

Copy the JavaBridge.jar, php-servlet.jar and php-script.jar of PHP/Java Bridge to 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;

 php.java.servlet.ContextLoaderListener   PhpJavaServlet php.java.servlet.PhpJavaServlet   PhpCGIServlet php.java.servlet.fastcgi.FastCGIServlet  prefer_system_php_exec On   php_include_java Off    PhpJavaServlet *.phpjavabridge   PhpCGIServlet *.php 
Copy after login

After completing the above steps, restart tomcat, you can execute the php script under any project, but it cannot be run directly under webapps/, because the tomcat official website explains cgiPathPrefix as follows:

The CGI search path will start at the web application root directory File.separator this prefix.

Directly access the file index.php in the webapps directory

Copy after login

Appear during access


#

The above is the detailed content of What should I do if tomcat does not support php?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!