Site icon RDR-IT

Install PHP with IIS on Windows Server 2025

After seeing how to install IIS on Windows Server 2025, we will move on to installing PHP on it.

This tutorial should work on earlier versions of Windows Server and second point: I advise you not to install PHP on IIS and more generally on Windows, which cannot provide good application performance and which is limited in the available extensions.

For me the only interest in going through IIS with a PHP application is the possible use of SSO.

Some time ago (see years), I wrote a tutorial on installing PHP on IIS, this manipulation was “easy” because we went through Web Platform in IIS which allowed this installation to be done using a “store”.

By clicking on the link that is still available on Windows Server 2025, on the download page, we have a message that tells us that it is no longer available since 12/31/2022.

So to put it simply, in this tutorial, we will see how to install PHP on IIS without going through Web Platform Installer (WPI).

Prerequisites for PHP on IIS

The first step will be to install Microsoft Visual C++ 2015-2022 in order for PHP to work on your IIS server, at the time of writing the tutorial, PHP is compiled with VS2016.

The second prerequisite is to have the CGI functionality of IIS installed.

If you don’t have it installed, just run the Add Roles and Feature Wizard and select CGI in the IIS role selection.

Download PHP for Windows

We will start with this step, which will be to recover PHP for Windows, you can download directly from the following site : https://windows.php.net/download/

For IIS, we will use the Non Thread Safe version, I will start by downloading version 8.3(.11) of PHP in Zip format.

Once downloaded, unzip the archive.

Move the archive and its contents to a folder dedicated to PHP versions on the server. I usually put them in the following folder: C:\PHP, then move the unzipped folder to the complete one inside.

It’s up to you to find out how you want to do it.

Test that PHP is working properly on Windows

From the Windows Terminal, go to the folder where the PHP files are located:

Then in the folder enter the following command:

.\php.exe -v

This returns the PHP version to the console.

This little test allows you to validate that Visual C++ is installed at the correct version on the server.

I’ll take this opportunity to make a small digression: if you’re used to Linux and want to use the php command from anywhere in Windows, you need to modify a PATH environment variable by indicating the parent folder of the php.exe file.

Personally, I never do this because I often tend to have multiple versions of PHP on the same server, so I have to remember to regularly update the environment variable path. I prefer to use full paths when I use the command line, such as for scheduled tasks, which allows me to control the version of PHP used.

Add PHP to IIS

Now that everything is ready, we will move on to configuring IIS, which is done by mapping, in short, we will tell IIS, when it encounters a .php file to send it to the php-cgi.exe executable.

From the IIS console, select server 1 in the navigation pane and click Handler Mappings 1.

We arrive at a list of already configured mappings, this is where we will add the .php link to the executable, in the Actions panel, click on Add a module mapping 1.

Here are the configuration elements:

To validate, click on the OK button 5.

Confirm the creation of the entry by clicking Yes 1.

The mapping is added at the server level.

We will now test the correct functioning of PHP, for this I will create a file named phpinfo.php which will be accessible from an IIS site with the phpinfo() function; which allows to have the PHP version information.

Then call the page from a browser, you should have this:

You can now host sites developed in PHP on IIS.

Customize PHP configuration

Now I will explain how to customize PHP configuration with php.ini file.

If you look at the previous screenshot, we can see that the Loaded configuration File directive is set to (none).

In this case, PHP is executed with all these default settings, if you need to modify them, you must go through the php.ini file.

In the folder where the php.exe executable is located, we have configuration templates:

Rename one of the two files to php.ini.

Restart 1 IIS for it to take effect.

Refresh the PHP information page and we can now see that the php.ini file is loaded.

You can now edit the php.ini file to adapt the configuration, do not forget to restart the IIS service for the changes to take effect.

It is also possible via specific configuration lines to load additional configuration files that allow different PHP configurations depending on the site. Here, the modifications in the php.ini file will be applied to all sites on IIS that use this version of PHP.

Multiple versions of PHP on IIS

To continue this tutorial, we will see how to put several versions of PHP on the same IIS server.

Start by downloading another version of PHP, here I will take 8.2.

As with the first version of PHP that you installed, unzip the archive and place it in the desired location on the server.

On the IIS console, still at the server level, go back to the Handler Mappings and add a module mapping again.

Similarly configure the new version of PHP as a module.

Both versions of PHP are configured, to see which version takes priority, click on Show sorted list 1.

In the screenshot below, we can see that the latest version that was added has priority, to change the order, simply select the configured mapping and use the arrows found in the Actions panel.

We will now modify the Demo-IIS site so that it uses PHP 8.2 and not PHP 8.3. To do this, select the site 1 and click on Handler Mappings 2.

Then click on Show sorted list 1.

Select the desired PHP version 1 and click Upgrade 2.

A message will appear stating that you will be “breaking” configuration inheritance in IIS for this setting, click Yes 1.

At the site level, the first version is now PHP 8.2.

On the default site, I also created a phpinfo.php file, as you can see in the screenshot below, I have two different versions of PHP on the two IIS sites.


Now you know how to install PHP and configure it on an IIS web server.

Exit mobile version