CGI, ISAPI, and FastCGI configuration methods

Source: Internet
Author: User

In Windows IIS 6.0, PHP is usually configured in CGI, ISAPI, and FastCGI. These three modes can be successfully run in IIS 6.0, the following describes the differences in configuration and performance of the three methods.

 
1. CGI (Common Gateway Interface/Common Gateway
Interface) is generally an executable program, such as an EXE file, and the WEB server occupies a different process, and generally a CGI program can only process one user request. In this way, when
A large number of user requests occupy a large amount of system resources, such as memory and CPU time, resulting in low efficiency.

2. ISAPI (Internet Server
Application Program
Interface) is a set of WEB service-oriented API interfaces provided by Microsoft. It can implement all the functions provided by CGI and is extended on this basis. For example, it provides a filter application Interface.
Port. Most ISAPI applications are used as DLL dynamic libraries. They can be executed after being requested by users. After processing a user request, they will not disappear immediately, but will continue to reside in the memory for processing.
User input. In addition, the isapi dll application is in the same process as the WEB server, and the efficiency is significantly higher than that of CGI.

On Windows Server

In IIS6 of 2003, configure the ISAPI-based PHP by adding a new WEB Service extension in the "WEB Service extension" of IIS. The program suffix is
In PHP, the ISAPI program is php5isapi. dll, and then add the variable name PHPRC to "environment variable"-"system variable". The value is the path of php. ini.
In Internet Information Service Manager, select the root directory of the website or application, open the directory properties page (right-click and select "properties"), and then select "main directory ". Click "Configure" and select ""
Click the Tab. Click "add..." and set the "executable file":
C: \ php \ php5isapi. dll. Set the extension to. php, select "check whether the file exists", and then "OK" to save the settings. Restart the server to complete the PHP configuration.

 
3. FastCGI is an open CGI extension of the Scalable Architecture. Its main behavior is to keep the CGI interpreter process in the memory and thus achieve high performance. The repeated loading of the traditional CGI interpreter is
The main cause of low CGI performance is that if the CGI interpreter remains in the memory and accepts FastCGI Process Manager scheduling, it can provide good performance and scalability.

FastCGI has been integrated into IIS7 and also supports IIS6. For the installation method in IIS6, refer to Microsoft's official documentation. Here is a simple translation.

Click here to download a 32-bit FastCGI extension for IIS, and then install it. The installed file should be in the system32 \ inetsrv directory.

Then open the system32 \ inetsrv directory and execute the following statement. c: \ php is your PHP Directory, which can be changed to another value.

Cscript fcgiconfig. js-add-section: "PHP"-extension: php-path: "c: \ php \ php-cgi.exe"

 
In Internet Information Service Manager, select the root directory of the website or application, open the directory properties page (right-click and select "properties"), and then select "main directory ". Click "Configure" and select
"Ing" Tab. Click "add..." and set the "executable file":
C: \ windows \ system32 \ inetsrv \ fcgiext. dll. Set the extension to. php, select "check whether the file exists", and click "OK" to save the settings.
.

Modify the php. ini file and add the following statement:

Fastcgi. impersonate = 1
Cgi. fix_pathinfo = 1
Cgi. force_redirect = 0

Then open the system32 \ inetsrv directory and execute the following statement:

Cscript fcgiconfig. js-set-section: "PHP"-InstanceMaxRequests: 10000
Cscript fcgiconfig. js-set-section: "PHP"-EnvironmentVars: PHP_FCGI_MAX_REQUESTS: 10000

Finally, configure the security of the c: \ php Directory so that the IIS_WPG group has the permission to read and execute the directory.

At this time, FastCGI-based PHP is successfully configured on IIS6.

However, according to my own tests, FastCGI's performance is not much higher than that of ISAPI. I don't know if IIS7 under Windows Server 2008 is better. Here is Microsoft's built-in FastCGI-based IIS7 PHP installation method.

Original article reprinted, please note: Reprinted from the moonlight blog [http://www.williamlong.info/]

Link: http://www.williamlong.info/archives/1846.html

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.