Three ways for PHP and web services to work

Source: Internet
Author: User
The Web server can generate Web pages using PHP in three ways.

The first method is to use PHP as a "shell ". Run in this way, PHP will generate and end a PHP interpreter thread for each PHP page request submitted to your web server. Since this thread ends with the end of each request, any resources used in this thread (such as connections to the SQL database server) will be closed with the end of the thread. In this case, you will not get any changes when using permanent connections-because they are not permanent at all.

The second and most common method is to use PHP as a module of a multi-process Web server. This method is only applicable to Apache at present. For a multi-process server, a typical feature is that a parent process is executed in coordination with a group of sub-processes, where a Web page is actually generated as a sub-process. Whenever a client sends a request to the parent process, the request is passed to a sub-process that is not occupied by other client requests. This means that when the same client sends a second request to the server, it may be processed by a different sub-process. After a permanent connection is enabled, all subsequent pages requesting SQL service can re-use the established SQL server connection.

The last method is to use PHP as a plug-in for multi-threaded web servers. Currently, PHP 4 supports ISAPI, wsapi, and nsapi (in Windows), which allows PHP to be used as Netscape FastTrack (iPlanet), Microsoft's Internet Information Server (IIS) and O 'Reilly's Website Pro. The behavior of permanent connection is essentially the same as the multi-process model described above. Note that PHP 3 does not support SAPI.
Related Article

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.