Presentation
In this tutorial, I will explain how:
- Install PHP on IIS
- Configure PHP with PHP Manager for IIS
- Website creation or vhost
- Run different PHP versions depending on the site
Prerequisites
For PHP implementation under IIS, you need a web server with the IIS service.
A tutorial is available: Windows Server: IIS installation.
PHP installation
From the IIS console, click Web Platform Installer 1 .
Wait while loading …
In the search box enter PHP 1 and press the Enter key.
All available PHP versions must be displayed, click on the button Add 1 .
Adding PHP to IIS by the Web platform installer also attempts to install PHP Manager for IIS A . Click on the Install 1 button.
On the new window that opens, click on I accept 1 .
Wait while downloading and installing PHP.
It is possible that the installation of PHP Manager is in error A depending on the version of Windows. The installation of PHP Manager is processed afterwards. Click on the Finish 1 button to close the wizard.
To check PHP activation, return to the IIS home page and click Manager Mappings 1 .
If the menu is not available, restart the IIS console.
Both versions of PHP 1 are installed.
The order of the modules is important, the mapping rules are read from top to bottom.
By double clicking on a record, it is possible to access the properties of the module.
Installing PHP Manager for IIS
Download the corresponding version of PHP Manager for your operating system here.
If the error message asking to install .NET Framework 2.0 appears, click No 1 and add by adding roles and features.
Click on Next 1 .
Accept license 1 and click Next 2 .
Close the installation wizard by clicking Close 1.
Close and restart the IIS console.
PHP configuration
From the IIS console, click PHP Manager 1 .
Since PHP Manager, it is possible to administer almost the entire configuration, manage extensions, add / remove versions of PHP …
IIS uses a configuration inheritance system, any server-level console changes will be applied to all sites if a different configuration is not configured.
Enable a PHP extension
From PHP Manager, click Enable or disable a 1 extension.
The set of extensions available on the server for the version of PHP that appears group by state. A the active extensions and B the inactive ones.
Select the extension you wish to activate 1 , right click on it and click on Activate 2 .
The extension goes into the group of activated 1 .
Return to the IIS home page and Restart 1 the IIS service for consideration.
Use different versions of PHP depending on the sites
In this part, we will see configure IIS to use a different version of PHP depending on the site (vhost).
Prerequisites for this part:
- Have multiple versions of PHP available on the IIS server.
- Create the DNS records in order to access the sites.
To illustrate the tutorial, we will set up two sites on IIS, which will work with two different versions of PHP (5 and 7).
Create the 1 folders that will receive the websites.
On the IIS interface, right click on Sites 1 and click on Add a website … 2 .
Enter the name of the site 1 , the folder where it will be hosted 2 , the full DNS name of the site 3 and click on the OK 4 button.
Do the same for the second site (php5.rdrit.lab).
Both sites 1 are now created.
In the folders that host the sites, create a new phpinfo.php file and enter the following code:
<?php phpinfo(); ?>
Launch an internet browser and enter the url of sites. They are normally on the same version (PHP 7.2.2).
Return to the IIS console, click on php5 1 and click on PHP Manager 2 .
Click Change version of PHP 1 , then in the window select version 2 and click on OK 3 .
The current version of PHP has been modified 1 .
Go to the site management and restart the 1 .
Return to the browser and refresh the page to see the version change with phpinfo 1 .