Home  >  Article  >  Backend Development  >  Comparison of ISAPI and FastCGI for PHP under IIS_PHP Tutorial

Comparison of ISAPI and FastCGI for PHP under IIS_PHP Tutorial

WBOY
WBOYOriginal
2016-07-13 17:39:53709browse

When configuring PHP under Windows IIS 6.0, there are usually three configuration methods: CGI, ISAPI and FastCGI. All three modes can run successfully under IIS 6.0. Now I will talk about the differences and performance of these three configuration methods. difference.

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

2. ISAPI (Internet Server Application Program Interface) is a set of API interfaces for WEB services provided by Microsoft. It can realize all the functions provided by CGI and expand on this basis, such as providing filter applications. program interface. ISAPI applications are mostly used in the form of DLL dynamic libraries, which can be executed after being requested by the user. They will not disappear immediately after processing a user request, but will continue to reside in the memory and wait for other user input to be processed. In addition, ISAPI's DLL application and WEB server are in the same process, and the efficiency is significantly higher than CGI.

Configure ISAPI PHP under IIS6 of Windows Server 2003. The configuration method is to add a new WEB service extension in the "WEB Service Extension" of IIS. The program suffix is ​​PHP and the ISAPI program is php5isapi.dll. Then add the variable name PHPRC in "Environment Variables" - "System Variables", and the value is the path to php.ini. In the Internet Information Service Manager, select the root directory of the website or application, and open the directory property page (right-click and select " Properties"), and then select "Home Directory". Click the "Configure" button and select the "Mapping" tab page. Click "Add...", set the "Executable File" to: c:phpphp5isapi.dll, set the extension to .php, select "Confirm whether the file exists", and then "OK" to save the settings. Restart the server to complete the PHP configuration.

3. FastCGI is an open extension of CGI with scalable architecture. Its main behavior is to keep the CGI interpreter process in memory and thus obtain higher performance. Repeated loading of traditional CGI interpreters is the main reason for low CGI performance. If the CGI interpreter remains in memory and accepts FastCGI process manager scheduling, it can provide good performance, scalability, etc.

FastCGI has been integrated into IIS7 and also supports IIS6. For the installation method in IIS6, please refer to Microsoft’s official documentation. I will briefly translate it here.

First click here to download a 32-bit FastCGI extension for IIS, and then install it. The installed file should be placed in the system32inetsrv directory.

Then open the system32inetsrv directory and execute the following statement, where c:php is your PHP directory and can be modified to other values.

 cscript fcgiconfig.js -add -section:"PHP" -extension:php -path:"c:phpphp-cgi.exe"

In the Internet Information Services Manager, select the root directory of the website or application, open the directory property page (right-click and select "Properties"), and then select "Home Directory". Click the "Configure" button and select the "Mapping" tab page. Click "Add...", set the "Executable File" to: c:windowssystem32inetsrvfcgiext.dll, set the extension to .php, select "Confirm whether the file exists", and then "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 system32inetsrv 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 read and execute permissions for this directory.

At this time, PHP based on FastCGI has been successfully configured on IIS6.

However, according to my own tests, the performance of FastCGI does not seem to be much higher than that of ISAPI. I wonder if IIS7 under Windows Server 2008 will be better. Here is the method provided by Microsoft to install PHP based on IIS7 with built-in FastCGI.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/486266.htmlTechArticleConfiguring PHP under Windows IIS 6.0, there are usually three configuration methods: CGI, ISAPI and FastCGI. These three modes All can be run successfully under IIS 6.0. Below I will talk about the zones configured in these three ways...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn