Step-by-step guide on how to install PHP on IIS in windows

IIS (Internet Information Server) is one of the most powerful web servers from Microsoft that is used to host Web applications. In this guide, first we will guide you how to install IIS on Windows 10. Then, we will also guide you on how to install PHP on IIS.  

Keeping with Microsoft modular design of, IIS in Windows is still an optional “Windows Feature”. To install it, follow the steps below

Step 1: Install IIS on Windows 10

  • Click Windows 10 Search Bar.
  • Type Control Panel.
  • Click Control Panel.

You can also press the Windows + R key combination to bring up a run box, then type appwiz.cpl and press enter.

  • Click Programs and Features.
  • Click Turn Windows features on or off.
  • Click Internet Information Services
  • Click World Wide Web Services
  • Click Application Development Features
  • Tick CGI.
  • Wait for the changes to be applied.

Step 2: Download PHP

  • Navigate to the link to download php
  • Choose 64 bit version. It should be Non Thread Safe, because it is recommended for IIS.
  • Click Zip, to download.
  • Extract the Zip folder to C:\. Directory and name it php.

Step 3: Configuring PHP.ini

  • Open php folder.
  • Copy ini-production file & Paste there in the same directory.
  • Rename the copied file as ini.
  • Right click on the ini file(php). Note that the extension .ini may not be visible.
  • Open with Notepad.
  • Press Ctrl + F to open search box. Depending on the text editor you are using, there are many ways to search/find
  • Use Up & Down radio buttons, because some of the lines are at top and some are at middle and some are at bottom.
  • Find the lines below in your php.ini, remove the “;” symbol from their start and make the changes, since “;” is a comment symbol which means such lines will not be executed.
  • Save these changes. 
  • Find — extension_dir = “./” —  Replace with —  extension_dir = “C:\PHP\ext”
  • 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 (remove “;”)

Find these lines below and remove only  (“;”) from their start.

  • extension=curl
  • extension=gd2
  • extension=mbstring
  • extension=mysqli
  • extension=pdo_mysql
  • extension=xmlrpc

Save the changes.

Step 4: Configuring the Environment Variables

  • Click Control Panel
  • Click System and Security
  • Click System
  • Click Advanced system settings
  • Click Environmental Variables
  • Select Path & click edit under the System variables Label.
  • Click New.
  • Type C:\php
  • Click OK

Step 5: Configure IIS

  • Type IIS on Windows Search Bar or Type Run.
  • Click Run.
  • Type inetmgr
  • Click OK
  • Click Handler Mappings
  • Click Add Module Mapping
  • On request path: type *.php
  • On Module, select FastCgiModule from dropdown menu
  • On Executable, browse: C:\php\php-cgi.exe
  • Name it anything, type FastCGI
  • Click OK.

Step 6: Test the PHP Version

  • On Windows Search Bar Type CMD
  • Right click on it and select as Run as administrator
  • Type php –version
  • You should see the php details as below

How To Run PHP On IIS In Windows 10 35

Note:  if you get the error VCRUNTIME140.dll, it’s because in your computer, The Visual C++ Redistributable Packages is not installed. To install it,

  • Check the C:\ drive whether the setup vc_redist.x64.exe is present or not.
  • Visit this link to download: 
  • Download Visual C++ Redistributable for Visual Studio 2015
  • Click Download.
  • Tick vc_redist.x64.exe
  • Click Next to begin downloading.
  • Click the setup to install.

Step 7: Test A PHP File

  • Open Notepad or any other text editor
  • Type a simple code in PHP or HTML as
  • Save As this file in: C:\inetpub\wwwroot as test.php
  • Check http://localhost/test.php on your browser’s URL bar.
  • You can see that I have successfully configured PHP on IIS in Windows 10

Note: If you encounter the error you don’t have permission to save in this location, follow the steps below

Step 1: Right-click the folder you want to save files to and select Properties from the context menu.

Step 2: Select Security tab in the pop-up window, and click Edit to change permission

Step 3: Select Administrators from the menu and check Full control in Allow column.

If Full Control is already checked, you might have to select any option from the Deny column and then check Full Control in Allow column again.

Step 4: After you’re done, click on Apply and OK to save changes.
Now repeat these steps for Users group if its available in Security section.

After giving Full control to the Administrators group the problem should be completely resolved and you’ll be able to save files to this directory without any problems.

Leave a Reply

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