In this article, you will discover the right steps to follow to enable the PHP configuration on your site. It is a good IIS practice to create application pool for every website. Now, if they are able to have their own Application Pool, it would be a very easy task to dedicate a FastCGI Process Pool to any of these sites. Hence, combining the arguments and fullpath properties clearly help you to recognize a FastCGI process pool.
Enabling Per-Site PHP Configuration
If you are required to generate many FastCGI process pools for each executable process like the php-cgi.exe, you can utilize the the arguments element to differentiate the definition of each of their process pool. By making use of php-cgi.exe protocols, you can additionally utilize the command line switch “-d” to delineate an INI access for a PHP protocol. Using this toggle to configure a PHP setting, you can make the arguments thread unique.
For instance, if you need two Websites “website1” and “website2” to be delineated their own distinct settings for PHP, you can define the e FastCGI system pools as illustrated below:
<fastCgi> <applicationfullPath="C:PHPphp-cgi.exe"arguments="-d open_basedir=C:WebsitesWebsite1" /> <applicationfullPath="C:PHPphp-cgi.exe"arguments="-d open_basedir=C:WebsitesWebsite2" /> </fastCgi>
In our illustration here, we used the PHP setting open_basedir to differentiate each of the process pool definitions. It is also enforced by the setting that the PHP that can be executed for every single process pool could perform only file operations linked inside the root folder of the Web site which corresponds to it.
Below is a mapping of a PHP handler for the Website 1:
<system.webServer> <handlersaccessPolicy="Read, Script"> <addname="PHP via FastCGI"path="*.php"verb="*"modules="FastCgiModule"scriptProcessor="C:PHPphp-cgi.exe|-d open_basedir=C:WebsitesWebsite1"resourceType="Unspecified"requireAccess="Script" /> </handlers> </system.webServer>
Also, below is a mapping of a PHP handler for the Website 2:
<system.webServer> <handlersaccessPolicy="Read, Script"> <addname="PHP via FastCGI"path="*.php"verb="*"modules="FastCgiModule"scriptProcessor="C:PHPphp-cgi.exe|-d open_basedir=C:WebsitesWebsite2"resourceType="Unspecified"requireAccess="Script" /> </handlers> </system.webServer>
Specifying php.ini location
At the beginning of the PHP process, it decides the position of the php.ini file used in configurations with numerous settings like the PHPRC environment variable. A complete description of the process involved in starting up the PHP is provided by the PHP Documentation. The PHPRC environment variable is among places the PHP process look for php.ini. In a situation when a file of the PHP process locates a php.ini file in the thread that is provided in the this environment variable, it will make use of it.
If it does not locate it, the process of the PHP would reverse back to make use of the php.ini file default location. This particular environment variable makes it possible to give hosting customers the chances to make use of their own php.ini files versions.
A good example is when two web sites tagged website1 and website 2 are positioned in the listed file paths specified below:
C:WebSiteswebsite1 and C:WebSiteswebsite2, you can configure the php-cgi.exe process pools in the <fastCgi> section of the applicationHost.config file like:
XMLCopy
<fastCgi> <applicationfullPath="C:PHPphp-cgi.exe"arguments="-d open_basedir=C:WebsitesWebsite1"> <environmentVariables> <environmentVariablename="PHPRC"value="C:WebSiteswebsite1" /> </environmentVariables> </application> <applicationfullPath="C:PHPphp-cgi.exe"arguments="-d open_basedir=C:WebSitesWebsite2"> <environmentVariables> <environmentVariablename="PHPRC"value="C:WebSiteswebsite2" /> </environmentVariables> </application> </fastCgi>
Therefore, following this pattern, Website1 can have a unique php.ini file version lying in the C:WebSiteswebsite1, and the Website 2 can have its own unique php.ini file version lying in the C:WebSiteswebsite2. PHP will make use of the php.ini default file located in that same folder as the php-cgi.exe location in a situation where a php.ini file located in the particular folder were not found in a location determined by the PHPRC environment variable.
Check out these top 3 Best web hosting services
- Looking for Top web hosting? Clicking on this link can be the solution.