in charge of a Web site that uses JSP Dynamic Web technology, just have a part of PHP writing function, so it is very straightforward to think that Tomcat support PHP. Tomcat is also Apache out, is it only support JSP? Is it possible to use PHP on tomcat? Search the Internet and soon have the answer to the first question: Tomcat can support CGI, such as Perl (see enclosure for specific settings). But continue to search, but have been unable to find a way for Tomcat to use PHP, is generally taken to install Apache and Tomcat coexistence method to build so-called support php+jspWeb Platform .
Windows operating system web.xml
<init-param><param-name>executable</param-name><param-value>php</param-value> </init-param>
and add the PHP installation path to path so that Tomcat can run toit's PHP.exe. After rebooting Tomcat, theWeb-infdirectory to create a new CGI directory, put the PHP file here, and then access the virtual map outCgi-bin Directoryto access these PHP files.
But if you don't make any changes to your PHP files, you may find that you don't have any output. Need to add a line to the header of the PHP file, output two carriage returns:
echo "\ n";
The reason is not very clear. May be waiting for content-type input, or Perl's CGI program style.
However, with this configuration, PHP (4.1.0 or later) $_request, $_get, $_posTSuch variables cannot be used, only querystring are obtained from the server variables or environment variables: $_server["query_string", "$_env[" query_string "]. The post submission of the form may not be supported ... I haven't tried it yet..
because of the Tomcat is not familiar with, so these are only in the current method of small repair, may have good practices, but also hope that everyone feel free!
Related recommendations:
How to install Tomcat7.0.82 under Linux
Introduction to several kinds of loaders in Tomcat
The overall structure of TOMCAT is detailed