Objective
To serve as a quick guide on how to manually install PHP of any version and set it as a default PHP version for a website in IIS server.
Prerequisites
- Windows Server 2019
- IIS Server
- PHP Manager for IIS
Steps
Step 1: Download PHP from official site
Download the PHP for Windows from the official site.
Extract the content of the zip file and rename it (eg: v8.1).
Move the file to a location dedicated for storing PHP files. For this article, the folder will be kept under C:\Program Files\PHP
Step 2: Set Environment Variable
Click on the Windows Start icon and type environment variables in the search bar.
Hitting Enter will bring up the System Properties window.
Click on the Environment Variables… button. This will bring up the Environment Variables window.
Under System variables, look for the Path variable and double click said entry.
From here, a new PHP path variable can be added by simply clicking on New and enter C:\Program Files\PHP\v8.X (depending on the version downloaded in Step 1).
Hit Save to apply the changes.
Step 3: Add PHP into IIS Server via PHP Manager
On the Windows Server, navigate to the Internet Information Services (IIS) Manager.
Select the server name and then PHP Manager.
Click on the Register new PHP version hyperlink.
Provide the path to the PHP executable file. For this case, the path will be C:\Program Files\PHP\v8.X\php-cgi.exe
Finally, hit OK.
To change the default PHP version of a website, simply select the website and click on the Change PHP version via the PHP manager.