How to deploy php project under tomcat

藏色散人
Release: 2023-03-17 11:18:02
Original
2329 people have browsed it

How to deploy php projects under tomcat: 1. Unzip php to the root directory of tomcat and change the folder name to php; 2. Add the path where php.exe is located to the path; 3. Modify the "tomcat/conf/context.xml" file; 4. Restart the tomcat service.

How to deploy php project under tomcat

The operating environment of this tutorial: Windows 7 system, PHP version 8.1, Dell G3 computer.

How to deploy php project under tomcat?

Deploy php under tomcat

Due to the need to test a PHP environment. Therefore, it is recorded here.

Environment

OS: win8.1 up1 64bit

tomcat: 8.0.14 64bit

php:php-5.6. 2-Win32-VC11-x64.zip

Extract php to the root directory of tomcat, change the folder name to php

Add the path where php.exe is located to the path.

Copy php.ini-development. Rename php.ini

Open extension_dir = "ext" option

Modify cgi.force_redirect to cgi.force_redirect = 0

Modify the tomcat/conf/context.xml file

Add the privileged="true" attribute to , that is:

Add

<servlet>  
    <servlet-name>php</servlet-name>  
    <servlet-class>org.apache.catalina.servlets.CGIServlet</servlet-class>  
    <init-param>  
      <param-name>clientInputTimeout</param-name>  
      <param-value>200</param-value>  
    </init-param>  
    <init-param>  
      <param-name>debug</param-name>  
      <param-value>0</param-value>  
    </init-param>  
    <init-param>  
      <param-name>executable</param-name>  
      <param-value>D:\tomcat\php\php-cgi.exe</param-value>  
    </init-param>  
    <init-param>  
        <param-name>passShellEnvironment</param-name>  
    <param-value>true</param-value>  
</init-param>  
    <init-param>  
      <param-name>cgiPathPrefix</param-name>  
      <param-value>WEB-INF/phpbin</param-value>  
    </init-param>  
     <load-on-startup>5</load-on-startup>  
</servlet>
Copy after login

to

<servlet-mapping>  
    <servlet-name>php</servlet-name>  
    <url-pattern>/phpbin/*</url-pattern>  
</servlet-mapping>
Copy after login

Restart the tomcat service:

In webapps\ROOT\ Create a new phpbin folder under WEB-INF

Create a new index.php

The content inside is:

<?php phpinfo();?>
Copy after login

http://localhost:8080/phpbin /index.php sees the following content. Indicates that the deployment is successful:

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of How to deploy php project under tomcat. 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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template