Goal: To allow .php files to run on a windows IIS 7.5 web server

Difficulty: Medium

Prerequisites: IIS 7.5 Webserver

With PHP being such a popular programming language for the web, it is important to understand how we can leverage our windows web server to run php. Below I will demonstrate how to install PHP 5.4 onto my brand new IIS7 web server. This server is running Windows 2008 r2 standard edition. A couple of disclaimers before I get started with the basic guide: You will need to adjust the paths in this guide suitable to your environment, I am using C: for my default website and S: (Secondary) drive for my program files (aka php installation). You will also need to make sure that you have the appropriate C++ runtime environment on your operating system. This is a fairly standard requirement so it is not included in this guide. Lastly, if you run into any problems or have question please feel free to reply to this thread or create your own and I will be more than happy to help you figure out what's going on (in my experience if you follow this guide and something isn't working it's a permission problem, or a php.ini configuration problem)

  1. The first step to making sure you can use PHP on your IIS server it to make sure you have CGI enabled. This can be done from the Server Manager under the Roles section.
    IIS7.5 with PHP 1.png
  2. Next leats head out to http://php.net/downloads.php and select the Windows {Version} binaries and source link.
    IIS7.5 with PHP 2.png
  3. Next make sure you download the "Non Thread Safe" zip file of the version you want. You may also notice that it says VC9 x86, this indicates that you will need the x86 version of the c++ 2008 package on your machine in order for php to run.
    IIS7.5 with PHP 3.png
  4. You will then be presented with some sort of download menu, if your using a browser that supports it just go ahead and open the zip file.
    IIS7.5 with PHP 4.png
  5. After you have the zip file opened go ahead and select "Extract all files" near the top left corner of the window.
    IIS7.5 with PHP 5.png
  6. Now extract these files to wherever you want your php installation to be located. For me I have this on a secondary drive under Program Files. Following the extraction go ahead and open up that folder as we have some work to do in that directory before we're done.
    IIS7.5 with PHP 6.png
  7. In your PHP installation directory copy your php.ini-production (or development depending on what kind of sites you are putting up on this box).
    IIS7.5 with PHP 7.png
  8. Then paste this file back in and rename it to be "php.ini".
    IIS7.5 with PHP 8.png
  9. In your php.ini file make sure you have the following set:
    open_basedir = {YOUR IIS WEBSITES PATH HERE}
    IIS7.5 with PHP 9.png
  10. After this set up your extensions you wish to have enabled and configure the rest of your php.ini file to your liking. Save and close the file.
    IIS7.5 with PHP 10.png
  11. Next Open up the Internet Information Services (IIS) Manager.
    IIS7.5 with PHP 11.png
  12. Select teh "Handler Mappings" for your server
    IIS7.5 with PHP 12.png
  13. Then click the "Add Module Mapping..." found in the top right corner of the Handler Mappings screen.
    IIS7.5 with PHP 13.png
  14. Then fill in the following information and click OK:
    Request Path:  *.php
    Module: FastCgiModule
    Executable (optional): [Enter the location of your php installation]\php-cgi.exe
    Name: PHP Via FastCGI
    IIS7.5 with PHP 14.png
  15. After you click OK you will be prompted: "Do you want to create a FastCGI application for this executable? Click 'Yes' to add the entry to the FastCGI collection and to enable this executable to run as a FastCGI application." to which you should click "Yes".
    IIS7.5 with PHP 15.png
  16. At this point you should have php running on your IIS server. To test, create a file called phpinfo.php in your default website directory (default is C:\inetpub\wwwroot\) and put the following code in the file and save it.
    IIS7.5 with PHP 16.png
  17. After you have added that file open a web browser on the server and go to http://localhost/phpinfo.php and you should see your php information if php is working properly. If not revisit the steps above and try and find what you might have missed.
    IIS7.5 with PHP17.png


Posted by samantha on
I done all of details but I have a big error
when i run http://localhost/phpinfo.php I have error 404 :(
Which is wrong?
What should i do?
Posted by Paul Rios on
Hello, I am having trouble trying to open the php file in your tutorial. I did everything in the steps word for word, but when i try to open the file i get the 'view and track your downloads' pop up box that opens instead of the file. Have you come across this before? Thanks for any help, I appreciate it.
Posted by Randy Middleton on
Very well done. Almost idiot proof details.
Do you, by chance, have instructions to upgrade php version? I did and upgrade using Web Platform Installer and something is still pointing to the previous version.
FastCGI settings has both 5.2 & v5.6. (If I take out 5.2 it all fails.)
Handler Mappings has only the 5.6.
PHP Manager shows 5.6.0 active.
phpinfo().php shows 5.2.17 active.
Posted by Budi BL on
Dear all,
I use "PHP Version 5.6.21", at the first time, i;ve got error like this:
"HTTP Error 500.0 - Internal Server Error
C:\Program Files (x86)\PHP\php-cgi.exe - The FastCGI process exited unexpectedly"
This error done by installing 'MSVC11 (Visual C++ 2012)" and copy the "msvcr110.dll" file to the "php-cgi.exe"'s folder.
I hope this will help.

Budi B L
Posted by greatx on
Tinedol - лучшеизлечит вас от грибка быстро и надежно
Posted by Gallant on
Hi i am doing all the steps but phpinfo.php not showing and give the error
The website cannot display the page
HTTP 500
Most likely causes:
•The website is under maintenance.
•The website has a programming error.
Please advice.
Leave a Reply

(Your email will not be publicly displayed.)