Do you want to set up PHP on IIS in Widows to run PHP applications and websites? You’re in the right place. In this tutorial, I will guide you step-by-step on how to install IIS in Windows, Download PHP, Configure PHP.ini, Configure the environment variables, Configure IIS for PHP, Test the PHP version, and Run a PHP file on IIS.
IIS (Internet Information Server) is one of the most powerful web servers from Microsoft that is used to host your Web applications. It provides localhost environment primarily to run (host) dynamic websites & web applications powered by ASP.NET & PHP.
PHP (Hypertext Preprocessor) is one of the most popular and widely used open-source server scripting languages used for creating dynamic websites and applications.
Following topics will be covered in this post:
- How to Install IIS on Windows
- How to Download & Extract PHP
- How to Configure PHP.ini File
- How to Configure the Environment Variables for PHP
- How to Configure IIS for PHP
- How to Test the PHP Version
- How to Run a PHP File on IIS
RELATED
- How to Download & Install WampServer on Windows
- How to Buy Domain & Hosting – Step by Step
- How to Install WordPress on XAMPP | Beginner’s Guide
01. How to Install IIS on Windows
In this section, I will guide you step-by-step on how to install IIS on Windows.
- Go to Windows Search Bar, located at your bottom-left corner.
- Type Control Panel.
- Click on the Control Panel from the search results.

- Click on the Programs and Features.

- Click on the Turn Windows features on or off link, located at your left side.

- Expand the Internet Information Services.
- Expand the World Wide Web Services.
- Expand the Application Development Features.
- Tick on the CGI.
- Click on the OK button.

- Wait for the changes to be applied.

- Once the changes are applied successfully you can see the message, “Windows completed the requested changes“.

02. How to Download & Extract PHP
In this section, I will guide you on how to download & extract the PHP.
- Go to PHP Official Website.
- Below the Binaries and sources Releases you can see the latest version of PHP. The PHP should be 64 bit version and Non Thread Safe, because it is recommended for IIS.
- Click on the Zip link, located below the VS16 x64 Non Thread Safe to download the PHP.

- Copy the Zip file to your C:\ Drive.
- Right-click on the Zip file and click on the Extract to php-version...

- Rename the extracted folder to PHP.

03. How to Configure PHP.ini File
In this section, I will guide you step-by-step on how to configure the PHP.ini file for IIS.
A PHP.ini is a simple text file that allows you to adjust PHP settings. It is the default configuration file for running the PHP-based applications.
- Open the PHP folder that you had extracted to C:\ Drive.
- Copy the php.ini-production file & Paste in the same folder(place).

- Rename the copied file to php.ini.

- Right click on the php.ini file.
- Go to Open With.
- Click on the Notepad.

- This is how your PHP.ini file looks like. The “;” is a comment symbol. The lines followed by “;” are not executed.
- Now you have to do two things (1) Make changes to lines listed below (2) Remove the “;” symbol from lines, listed below.

- Press Ctrl + F5 to open the Search Box.
- Find the below lines in your php.ini. Remove the “;” symbol and make the changes, which I have made.
- Save the changes.
Find extension_dir = "./" Replace with extension_dir = "C:PHPext"
Find fastcgi.impersonate=0 Replace with fastcgi.impersonate=1
Find cgi.fix_pathinfo=0 Replace with cgi.fix_pathinfo=0
Find cgi.force_redirect=1 Replace with cgi.force_redirect=0
Find error_log = php_errors.log and remove ";"
- Find the below lines in the php.ini file and remove only “;” from their beginning.
- Save the changes.
extension=curl
extension=gd
extension=mbstring
extension=mysqli
extension=pdo_mysql

04. How to Configure the Environment Variables for PHP
In this section, I will guide you step-by-step on how to configure the Environment Variables for PHP in Windows.
- Open the Control Panel.
- From View by: choose Category.
- Click on the System and Security.

- Click on the System.

- Click on the Advanced system settings link, located under the Related settings.

- Click on the Environmental Variables… button.

- Under the System variables, select Path & click on the Edit… button.

- Click on the New button.

- Type C:\PHP.
- Click on the OK button.

05. How to Configure IIS for PHP
In this section, I will guide you step-by-step on how to configure IIS for PHP in Windows.
- Type Run in the Windows Search Bar.
- Click on the Run from the search results.

- Type inetmgr in the Open: field.
- Click on the OK button or press Enter.

- Click on the Handler Mappings.

- Click on the Add Module Mapping.. link located under the Actions.

- In Request path: type *.php.
- In Module: select FastCgiModule from the dropdown list.
- In Executable (optional), type C:\PHP\php-cgi.exe. You can also add this .exe file using the Browse (…) button.
- In the Name type a name like FastCGI.
- Click on the OK button.

- It will prompt your permission to create a module mapping application for this executable. Click on the Yes button.

- You can see that the Module Mapping is created and enabled.

06. How to Test the PHP Version
In this section, I will guide you on how to test the PHP version in Windows to know whether it is fully-functional or not.
- On Windows Search Bar type CMD.
- Right click on CMD and select Run as administrator.

- Type php -version.
- Press the Enter button.

- You can see that it is showing the information about PHP version and Visual C++ Redistributable package’s version which is NTS Visual C++ 2019 x64.

If Visual C++ Redistributable Package is not installed on your computer, you may receive the error, “The code execution cannot proceed because VCRUNTIME140.dll was not found. Reinstalling the program may fix this problem“.
You can download Visual C++ Redistributable Packages from Microsoft.
07. How to Run a PHP File on IIS
Everything required to run PHP on IIS in Windows is set up, now it is time to run a PHP file.
- Right-click on the Notepad.
- Click on the Run as administrator.

- Copy and Paste this code in your Notepad file.
<html>
<head>
<title>PHP Test</title>
</head>
<body>
<?php echo "<h2>Thanks Meer's World for helping me to set up PHP on IIS </h2>"; ?>
</body>
</html>

- Go to File and click Save As…

- Browse the wwwroot directory on C:\ Drive. This is the complete path: C:\inetpub\wwwroot.
- Info: The inetpub is the default folder for IIS. It is the folder that contains website content and web apps. The wwwroot is the root directory of IIS. IIS executes the projects, apps, and websites deployed (placed) in the wwwroot.
- In the Filename type test.php.
- In Save as type select All Files (*.*).
- Click on the Save button.

- You can see that the test.php is saved to wwwroot directory.

- Open your browser and type http://localhost/folder or file name. For test.php file, I will type this: http://localhost/test.php.
- You can see that the test.php is run without any error. It means that I have successfully set up PHP on IIS in Windows.

If you like this post, don’t forget to share with other people. Share your feedback in the comments section below.
Also Read
- How To Install & Configure XAMPP On Windows 10 – Step By Step | For Beginners
- How To Change The XAMPP Server Port In Windows 10 | XAMPP Apache Server Port | Fix Apache Port Error
- How To Install MAMP On Windows 10 Step By Step | How To Change The MAMP Server Ports
- How To Install WordPress On MAMP Server In Windows 10 – Step By Step | Install WordPress On Localhost

Meer Basit is the founder of Meer’s World. He’s been running the show since launching the blog back in 2018. By background he is a computer scientist. Primarily, he creates content around blogging (WordPress, Blogger, Tumblr), SEO, affiliate programs, earn-online, reviews, eCommerce, & technology. He has got years of professional experience in web programming, computer programming, databases, data warehousing, & transcription. In general, he likes traveling, gardening, creating TikToks(@iammeerbasit), watching movies, is a passionate cricketer, creative writer, and a GSD lover.

Pedro Lucas
December 13, 2019 at 11:33 am
Thank you so much for such a magnificent tutorial. I was struggling to install IIS on Windows 10 for PHP, but now I have done it.
Meer Basit
December 15, 2019 at 2:31 am
You’re most welcome, Pedro!
Unknown
January 19, 2020 at 4:57 am
Thank You so much. It works briliantly!!
Meer Basit
January 20, 2020 at 2:32 am
You’re welcome!
Unknown
March 20, 2020 at 4:08 pm
Awesome tutorial. How anyone would do this without this info.
Meer Basit
March 21, 2020 at 2:34 am
You’re most welcome!
AALBC.com
July 2, 2020 at 1:53 pm
Perfect instructions other sites left out important steps — thanks!
Meer Basit
July 3, 2020 at 2:36 am
You’re most welcome!
Unknown
July 28, 2020 at 5:06 pm
Thank you SO MUCH! Hooked me UP!
Was sweating the prospect of getting PHP running on a new, extremely powerful laptop.
This tutorial was spot-on.
Thanks for posting it!
Stay safe out there.
Meer Basit
July 29, 2020 at 2:39 am
So nice of you! I appreciate your kind words! Thanks.
Anonymous
August 24, 2020 at 6:36 am
Great guide. It is accurate. Thank you a lot
Meer Basit
August 25, 2020 at 2:40 am
You’re welcome!
Unknown
October 15, 2020 at 10:54 am
Great guide, I was facing this issue since two days and there was no solution. Thanks you very much.
Meer Basit
October 16, 2020 at 2:41 am
You’re most welcome!
Unknown
October 18, 2020 at 1:47 pm
I am facing an issue (as below) during the installation of "Composer" application. Can you help me?
"
The Composer installer script was not successful [exit code 1].
Script Output:
The "https://getcomposer.org/versions" file could not be downloaded: failed to open stream: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. "
Meer Basit
October 18, 2020 at 2:43 pm
Please read this article it could help you: https://github.com/composer/windows-setup/issues/91
Meer Basit
October 18, 2020 at 2:46 pm
Read this article if above does not work: https://stackoverflow.com/questions/60408035/the-composer-installer-script-did-not-run-correctly-exit-code-1
Unknown
October 21, 2020 at 6:43 am
Thanks brother, its was done just I connect through my personal hotspot, my official network (WIFI) was not allowing.
I am actual new self learner and I am facing much difficulties, like now I stuck to render Twig elements in PHP on IIS server. Since yesterday I am trying but its not showing any result.
Sorry I am bothering you again and again. If can help me in this Twig issue, I will be very thankful to you.
BR, Muhammad Azhar Farooq
Meer Basit
October 22, 2020 at 2:49 am
No problem! You’re always welcome. To be honest I don’ have idea about Twig Elements, but I am suggesting 3 articles that may help you.
https://ourcodeworld.com/articles/read/1127/how-to-render-a-twig-view-inside-a-command-in-symfony-5
https://www.codegrepper.com/code-examples/php/twig+render+string+
https://symfony.com/legacy/doc/cookbook/1_0/en/web_server_iis
Unknown
October 22, 2020 at 12:09 pm
Many thanks, now at least some simple Twig templates showing contents but with some functions, conditions and loops are not rendered properly, just showing blank white page.
Thanks again.
Meer Basit
October 23, 2020 at 2:57 am
You’re most welcome!
Anonymous
December 8, 2020 at 5:39 pm
Thanks a lot. This is what any step by step should be
Meer Basit
December 9, 2020 at 2:58 am
You’re most welcome!
Unknown
January 4, 2021 at 11:34 am
Thank you so much with the help of your instructions I'm successfully install IIS on windows 10.
Meer Basit
January 5, 2021 at 3:00 am
You’re most welcome!
Unknown
May 30, 2021 at 5:08 am
Very useful post. I wasted a lot of time on http error 404.3 while trying to use wordpress for the first time before I came across this post. Solved the problem. Thank you
Meer Basit
May 30, 2022 at 3:00 am
You’re most welcome!