How To Enable Per-Site PHP Configuration And Specify Php.Ini Location

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

HostArmada
£1.98 /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
£0.79 /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.30 /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 Install MySQL on a Windows Web Server Running Apache

This tutorial will show you how to install the MySQL database on a Windows serve
3 min read
Michael Levanduski
Michael Levanduski
Expert Hosting Writer & Tester

How to Install OpenCart on an Ubuntu 18.04 Server or VPS with Apache, MariaDB and PHP 7

In this how-to, you'll learn how to install OpenCart, an open source shopping ca
3 min read
Angela Olaru
Angela Olaru
Senior Writer & Hosting Expert

How to Configure PHP Versions and Options on cPanel

This guide will show new webmasters about switching to different PHP versions an
2 min read
Avi Ilinsky
Avi Ilinsky
Hosting Expert

How To Install Apache, MySQL & PHP on an Ubuntu 18.04 VPS or Dedicated Server

This article shows users how to setup PHP, Apache web server and MySQL database
4 min read
Idan Cohen
Idan Cohen
Marketing 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