How to correctly implement Tomcat support PHP_PHP tutorial

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

 
 
  1. < init-param>
  2. < param-name>executable< /param-name>
  3. < param-value>php< /param-value>
  4. < /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...

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.