How to Configure FastCGI Recycling Settings Using of IIS Manager & Command Line

How to Configure FastCGI Recycling Settings Using of IIS Manager & Command Line

You need to always certify that FastCGI recycles the php-cgi.exe protocols long before the start of the PHP recycling starts locally. The FastCGI system recycling attitude is determined by the setup attribute- instanceMaxRequests.

This attribute indicates the number of queries the FastCGI system will manage before it goes through a recycling process. PHP as well possess related system recycling attribute that is managed by the setting variable PHP_FCGI_MAX_REQUESTS. When you configure the instanceMaxRequests with the value less than or equal to PHP_FCGI_MAX_REQUESTS, it guarantees that the local PHP system recycling logic will not trigger off.

The FastCGI settings can be set up either with the use of IIS Manager or with the use of the command line tool A ppCmd.

A: How to Configure FastCGI Recycling Settings With IIS Manager

Step 1:
Confirm Administration Pack For IIS installation

Check to confirm if the Administration Pack for IIS is set up on your server.

To do this, navigate to the IIS Manager and open it. Go to the server level and click FastCGI Settings twice.

Step 2:
Choose the FastCGI App To Set Up

When you select the application for configuration, go to the Actions panel and hit on the tab, Edit.

Step 3:

Configure Settings On The Edit FastCGI App

Navigate to the In the Edit FastCGI Application dialog box, set the InstanceMaxRequeststo 10000. Adjacent to the EnvironmentVariablessetting,hit on the Browse (…) tab.

Step 4:
Integrate The PHP_FCGI_MAX_REQUESTS Setting

Go to the EnvironmentVariables Collection Editor dialog box, integrate the PHP_FCGI_MAX_REQUESTS environment variable and configure it with 10000 Value.

If you do not set these up, these settings-: instanceMaxRequests= 200,
PHP_FCGI_MAX_REQUESTS= 500 (on most PHP builds) will be integrated by default.

B: Setting Up FastCGI Recycling With The Command Line

To set up the recycling behavior of FastCGI and PHP with the use of AppCmd implement the following directives:

consoleCopy

C:>%windir%system32inetsrvappcmd set config -section:system.webServer/fastCgi /[fullPath='c:{php_folder}php-cgi.exe'].instanceMaxRequests:10000
C:>%windir%system32inetsrvappcmd.exe set config -section:system.webServer/fastCgi /+"[fullPath='C:{php_folder}php-cgi.exe'].environmentVariables.[name='PHP_FCGI_MAX_REQUESTS',value='10000']"

Putting PHP Versioning Into Consideration

Majority of PHP apps depend on functions or features accessible through specific PHP versions. If you want to host these apps on one a single server, you must set various PHP versions to run alongside each other. The IIS FastCGI handler entirely provides support for running many versions of PHP on the single Web server.

For instance, suppose that you intend to permit PHP 4.4.8, PHP 5.2.1, and PHP 5.2.5 non-thread safe to run on your server. For the configuration to apply, you must position equivalent PHP binaries in different folders on the file system (e.g. C:php448, C:php521 and C:php525nts) and after that generate FastCGI app system pools for every PHP edition:

consoleCopy

C:>%windir%system32inetsrvappcmd set config /section:system.webServer/fastCGI /+[fullPath='c:php448php.exe']
C:>%windir%system32inetsrvappcmd set config /section:system.webServer/fastCGI /+[fullPath='c:php521php-cgi.exe']
C:>%windir%system32inetsrvappcmd set config /section:system.webServer/fastCGI /+[fullPath='c:php525ntsphp-cgi.exe']

If you manage three Web sites (site1, site2, site3) and each one of them needs to make use of a distinct PHP edition, you can then specify handler mappings on every one of those sites to serve as a reference for the equivalent FastCGI app system pool. However, you need to be aware that Each FastCGI system pool is specifically recognized with an amalgamation of fullPath and arguments attributes.

consoleCopy

C:>%windir%system32inetsrvappcmd set config site1 -section:system.webServer/handlers /+"..[name='PHP448_via_FastCGI',path='*.php',verb='*',modules='FastCgiModule',scriptProcessor='c:php448php.exe',resourceType='Either']
C:>%windir%system32inetsrvappcmd set config site2 -section:system.webServer/handlers /+"..[name='PHP521_via_FastCGI',path='*.php',verb='*',modules='FastCgiModule',scriptProcessor='c:php521php-cgi.exe',resourceType='Either']
C:>%windir%system32inetsrvappcmd set config site3 -section:system.webServer/handlers /+"..[name='PHP525nts_via_FastCGI',path='*.php',verb='*',modules='FastCgiModule',scriptProcessor='c:php525ntsphp-cgi.exe',resourceType='Either']

Enabling per-site PHP Configuration

This part of the guide tells you how you can enable per-site PHP configuration.

Per-site PHP Process Pools

When all your websites have unique application pool, which frequently the standard for operating a website on IIS, it is likely to link a dedicated FastCGI process pool with every one of your websites. A FastCGI system pool is exclusively recognized by merging fullPath and arguments properties.

If you are required to generate a lot of FastCGI process pools for that particular executable process like the php-cgi.exe, you can utilize the arguments feature to differentiate the definitions of the process pool.

With php-cgi.exe systems, you can as well utilize the command line switch “-d” to identify an INI entry for a PHP process. You can utilize this toggle to configure a PHP setting that ensures the arguments thread inimitable.

For instance, if you have two Web sites “website one” and “website two” that need to possess a distinct group of PHP settings, the FastCGI system pools can be configured by the command below:

XMLCopy

<fastCgi>
        <applicationfullPath="C:PHPphp-cgi.exe"arguments="-d open_basedir=C:WebsitesWebsiteone" />
        <applicationfullPath="C:PHPphp-cgi.exe"arguments="-d open_basedir=C:WebsitesWebsitetwo" />
</fastCgi>

In a scenario like this, the PHP setting open_basedir is employed to differentiate between the system pool definitions. The setting as well also shows that the PHP implementation for every one of the process pool can carry out file processes just inside the root folder of the resultant website.

After that website1 will possess the PHP handler mapping shown below:

XMLCopy

<system.webServer>
        <handlersaccessPolicy="Read, Script">
            <addname="PHP via FastCGI"path="*.php"verb="*"modules="FastCgiModule"scriptProcessor="C:PHPphp-cgi.exe|-d open_basedir=C:WebsitesWebsiteone"resourceType="Unspecified"requireAccess="Script" />
        </handlers>
</system.webServer>

and website two could possess the PHP handler mapping shown below:

XMLCopy

<system.webServer>
        <handlersaccessPolicy="Read, Script">
            <addname="PHP via FastCGI"path="*.php"verb="*"modules="FastCgiModule"scriptProcessor="C:PHPphp-cgi.exe|-d open_basedir=C:WebsitesWebsitetwo"resourceType="Unspecified"requireAccess="Script" />
        </handlers>
</system.webServer>

Conclusion

The FastCGI recycling setting can be configured either through the IIS manager or through the command line. We have covered in this guide all you need to know about the process and provide you step-by-step tips on the things you need to do to get it done.

Check out these top 3 Best web hosting services

HostArmada
$2.49 /mo
Starting price
Visit HostArmada
Rating based on expert review
  • User Friendly
    4.5
  • Support
    4.5
  • Features
    4.5
  • Reliability
    4.5
  • Pricing
    4.0
IONOS
$1.00 /mo
Starting price
Visit IONOS
Rating based on expert review
  • User Friendly
    4.5
  • Support
    4.0
  • Features
    4.5
  • Reliability
    4.5
  • Pricing
    4.3
Ultahost
$2.90 /mo
Starting price
Visit Ultahost
Rating based on expert review
  • User Friendly
    4.3
  • Support
    4.8
  • Features
    4.5
  • Reliability
    4.0
  • Pricing
    4.8

How To Add A FastCGI Environment Variable For PHP

This article tells you steps to add FastCGI environment for PHP in the IIS Manag
7 min read
Vladimir Rakov
Vladimir Rakov
Hosting Expert
HostAdvice.com provides professional web hosting reviews fully independent of any other entity. Our reviews are unbiased, honest, and apply the same evaluation standards to all those reviewed. While monetary compensation is received from a few of the companies listed on this site, compensation of services and products have no influence on the direction or conclusions of our reviews. Nor does the compensation influence our rankings for certain host companies. This compensation covers account purchasing costs, testing costs and royalties paid to reviewers.
Click to go to the top of the page
Go To Top