Main steps:
1. Turn on Tomcat CGI
2. Add php-cgi as a CGI executor
3. Modify the CGI execution path prefix, so that all the paths under the project PHP files can be executed
Detailed steps:
1. Turn on Tomcat CGI.
Refer to the Tomcat website method (http://tomcat.apache.org/tomcat-7.0-doc/cgi-howto.html)
(1) Open the Conf/web.xml, find the servlet and servlet-mapping in the name of CGI, and remove their comments. (Tomcat configuration file by default is a CGI configuration instance, but initially is annotated, if not can be searched on the internet)
(2) Open conf/context.xml, add privileged= "true" attribute to The label.
The above configuration is for Tomcat global, if it is for a certain application, you need to copy the corresponding configuration to the corresponding web-inf.
2. Add php-cgi as a CGI executor
First make sure that PHP is installed correctly and execute the php-cgi command at the terminal.
Open Conf/web.xml and locate the CGI-named servlet, where you add the following configuration:
Executable
php-cgi
3. Modify the CGI execution path prefix
This section is designed to allow PHP files to be executed directly. The default CGI configuration is that PHP files need to be placed under the web-inf/cgi of the project and then accessed cgi-bin/xxx.php to execute.
(1) Modify the Cgipathprefix under the servlet and change the web-inf/cgi to/, as follows:
Cgipathprefix
/
(2) Modify the CGI under Servlet-mapping, change the/cgi-bin/* to *.php, as follows:
Cgi
*.php
After completing the above steps, restart Tomcat, you can execute PHP script under any project, but cannot run directly under webapps/, because the Tomcat website interprets Cgipathprefix as follows:
The CGI search path would start at the Web application root directory + File.separator + this prefix.
Above.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
The above describes the Linux tomcat under the configuration of PHP operating environment, including the aspects of the content, I hope that the PHP tutorial interested in a friend helpful.