Home > Backend Development > PHP Tutorial > Configure php running environment under linux tomcat

Configure php running environment under linux tomcat

WBOY
Release: 2016-08-08 09:19:02
Original
2634 people have browsed it

Main steps:
1. Open tomcat's cgi
2. Add php-cgi as the executor of cgi
3. Modify the cgi execution path prefix so that php files in all paths under the project can be executed
Detailed steps:
1. Turn on cgi of tomcat.
Refer to tomcat official website method (http://tomcat.apache.org/tomcat-7.0-doc/cgi-howto.html)
(1) Open conf/web.xml and find the servlet and servlet-mapping named cgi , remove their comments. (Tomcat’s configuration file has a cgi configuration instance by default, but it is commented at the beginning. If it is not found, you can search it online)
(2) Open conf/context.xml and add the privileged="true" attribute to the tag.
The above configuration is for tomcat globally. If it is for a certain application, you need to copy the corresponding configuration to the corresponding WEB-INF.
2. Add php-cgi as the cgi executor
First make sure that php is installed correctly and execute the php-cgi command in the terminal.
Open conf/web.xml, find the servlet named cgi, and add the following configuration to it:

executable
php-cgi

3. Modify the cgi execution path prefix
This part is to allow the php file to be executed directly. The default cgi configuration is: you need to put the php file under WEB-INF/cgi of the project, and then access cgi-bin/xxx.php to execute.
(1) Modify the cgiPathPrefix under the servlet and change WEB-INF/cgi to /, as follows:

cgiPathPrefix
/

(2) Modify cgi under servlet-mapping, change /cgi-bin/* to *.php, as follows:

cgi
*.php

After completing the above steps, restart tomcat. The php script can be executed 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.

and above.

Copyright Statement: This article is an original article by the blogger and may not be reproduced without the blogger's permission.

The above introduces the configuration of the PHP running environment under Linux tomcat, including aspects of the content. I hope it will be helpful to friends who are interested in PHP tutorials.

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