Introduction
My client gave me a question that they have a windows server which hosting multiple applications using IIS and some of apps are build with PHP and the version is 5.* and the new application they want to deploy is building with Laravel which required version 7.
So we are talking about “How to run multiple versions of PHP in IIS”.
Internet Information Services (IIS) server already supported PHP by extension and also able to specific version of PHP by application. — Here
After some google I found it so I think it’s good idea to have it on Medium.
Step 1: Validate your current version of PHP
Create phpinfo.php file and place in your test site
Visit your phpinfo.php file to validate the current version
This case is 5.3
Step 2: Install new version of PHP using Web Platform Installer (Web PI)
Open Web Platform Installer in IIS Manager
Search for “php” and look for “PHP 7.*” or the version you want then click Add.
Once clicked Add the required component will be also addedClick I Accept, and wait for the download and installation.
Once it’s done click Finish, Now go and check you phpinfo.php if it works or not? if not please continue.
Step 3: Configuration
Validate FastCGI Settings by open the module
You will see new version (PHP7.2) is already set into FastCGI Settings. If not or you are already install with other way, click Add Application… and create one.
Now go to you Web Site, select Config Handler Mappings
Find *.php in Path column. You will notice that there is only old version mapped so we need to add new mapping by click Add Module Mapping…
Fill in the information
Note: Executable must be set to php-cgi.exe with specific version of PHP
Click Request Restrictions…, At Mapping select File or folder
At Verbs select All verbs or up to you.
At Access select Script
Click OK, then it will ask you the permission, click Yes.
Now try to refresh the phpinfo.php file you will see new version of PHP is executed.
Reorder the priority of version of PHP
In case you want to switch between versions, right click at the list of mappings and click View Ordered List…
Try to move it up/down by right click and click Move Up/Down
Now try to refresh phpinfo.php file you will see the version is changed.