How to correctly implement Tomcat to support PHP. In this article, we have explained in detail how Tomcat supports PHP and hope to help you. In charge of a website using JSP dynamic web page technology, we have explained in detail the methods related to Tomcat's support for PHP in this article, and hope to help you. When responsible for a website using JSP dynamic web page technology, some of the features are written on hand, so it is very straightforward to think of making Tomcat support for PHP.
Tomcat is also from Apache. does Tomcat only support JSP? Can I use PHP on Tomcat? I searched the internet and soon got the answer to the first question: Tomcat can support CGI, such as Perl.
However, you cannot find a way to allow Tomcat to support PHP. Generally, you can build a so-called Web platform that supports PHP + JSP by installing the coexistence of Apache and Tomcat.
Of course, PHP itself also supports CGI, so I tried it myself (on a Windows operating system): first let Tomcat support CGI according to the appendix, then modify the web. xml, add the following configuration in the servlet-name cgi section:
- < init-param>
- < param-name>executable< /param-name>
- < param-value>php< /param-value>
- < /init-param>
Add the PHP installation plugin to the pathpath. In this example, Tomcat can run php.exe. Restart Tomcat, create a new cgi directory under the WEB-INF Directory, put the php file here, and then access these php files with the cgi-bin directory that is virtualized ING.
However, if you do not add any changes to the PHP file, you may find no output. You need to add a line in the PHP file header and output two carriage returns: echo "nn". The reason is not clear. It may be waiting for the Content-type input or the cgi program style of Perl.
However, in PHP (version 4.1.0 or later), variables such as $ _ REQUEST, $ _ GET, and $ _ POST cannot be used, queryString can only be obtained from SERVER variables or environment variables: $ _ SERVER ["QUERY_STRING"], $ _ ENV ["QUERY_STRING"]. It may not support form POST submission ...... I have not tried it yet.
I am not familiar with Tomcat, so these are just minor repairs on the current method. There may be good practices for Tomcat to support PHP. I hope you will not give me any advice!
Bytes. When you are in charge of a website using JSP dynamic web page Technology...