Configure PHP Runtime environment under Linux Tomcat

Source: Internet
Author: User
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.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.