How to install PHP on an IIS Web Server

(Last Updated On: 2019-11-07)

I recently found a piece of software that I am exploring to help me manage our current IT environment. To install this I require two applications setup. A PHP web server and a MySQL database.
Following below is an example of how to:
Install IIS with PHP on a Windows 2019 Server.

Install IIS

Once the server is installed browse to server manager and choose
“Add Roles and Features”:

Server ManagerAdd Roles and FeaturesIIS

Click next until you get the “Server Roles” and choose the option
“Web Server (IIS)”.
An Option will appear to include Management tools click “Add Features”.

Server ManagerAdd Roles and FeaturesServer RolesIIS

Add Features

Server ManagerAdd Roles and FeaturesServer RolesAdd FeaturesIIS

Continue to click next until you get to “Role Services” Browse to “Application Development” Expand it then add the option for “CGI”.
If you are interested in creating a Company Directory from your Domain controller you can choose ASP as well.

Server ManagerAdd Roles and FeaturesIISCGI

Click next and install and wait for is to complete. To test it open the web browser on the machine you installed it on and browse to http://localhost/
If you get an Internet Information Services page the installation was successful.

IISLocalHostInternet Information Services

Install Microsoft Visual C++

Before actually installing PHP you install Visual C++. It is quick and easily opens the EXE click Agree and Install.

Microsoft Visual C++

Install PHP

To install PHP you extract the zip file you downloaded to a directory of your choosing. I suggest creating a directory in one of the Program Files directory’s so not to delete it by accident if you clean your root directory’s one day. For this, I extracted it to the C:\ root as this is just a demo Server.


Once extracted browse to the folder and rename the file php.ini-production to read only php.ini.

Edit the newly named file and amend the following Lines.
Remember to make sure the directory location corresponds to where you extracted the files.

Old ValueNew Value
;cgi.force_redirect = 1 cgi.force_redirect = 0
;fastcgi.impersonate = 1 fastcgi.impersonate = 1
;extension_dir = “./” extension_dir = “C:\php\ext”

Configure PHP in IIS

The last steps is to tell IIS where to find PHP and how to use it.
Open IIS browse to the server and choose Handler Mappings.

IISHandler Mappings

Add Module Mapping and fill in the Mapping as per the below screenshot.

IISHandler MappingsAdd ModulePHPCGI

Click ok to save then browse back to the IIS Server page.
Choose FastCGI Settings.

IISPHPFastCGI Settings

Click Collection then add. Fill in the following details:


Restart IIS by opening Command Prompt in administrator mode
Type iisreset and Enter.


Test PHP

To test PHP browse to the IIS root directory and create a new file called phpinfo.php.


In the new file type the following code Exactly :


Browse to http://localhost/phpinfo.php if you get a screen as per the below you successfully installed PHP.



If you liked what you read Please Share.
I’d love it if you followed me on YouTube and Facebook.

Also, feel free to subscribe to my posts by email.
Donations for the site can be made here.

Thanks for reading.
Spread the love

Leave a Reply

Your email address will not be published. Required fields are marked *