Install PHP and use it with IIS
suggest changeIIS (Internet Information Services) must already be installed. It is not installed by default. Add it from Control Panel, Programs, Turn Windows features on or off.
- Download PHP from http://windows.php.net/download/. For IIS FastCGI, use a Non-Thread Safe (NTS) build.
- Extract the files into
C:\PHP\. - Open Internet Information Services (IIS) Manager.
- Select the root item in the left panel.
- Double click on
Handler Mappings. - On the right side panel click on
Add Module Mapping. - Setup the values like this:
Request Path: *.php
Module: FastCgiModule
Executable: C:\PHP\php-cgi.exe
Name: PHP_FastCGI
Request Restrictions: Folder or File, All Verbs, Access: Script
- Install the Visual C++ redistributable that matches the PHP build. The Visual C++ 2012 package matches older PHP builds. Current PHP 8 builds need a newer Microsoft Visual C++ redistributable.
- Setup your
C:\PHP\php.ini, especially set theextension_dir ="C:\PHP\ext". - Reset IIS from a command prompt with
IISRESET.
The PHP Manager for IIS project on CodePlex is retired. Configure php.ini directly.
Remember to set index.php as one of the default documents for IIS.
After those steps, PHP can be tested.
Just like Linux, IIS has a directory structure on the server, the root of this tree is C:\inetpub\wwwroot\, here is the point of entry for all your public files and PHP scripts.
Now use your favorite editor, or just Windows Notepad, and type the following:
<?php
header('Content-Type: text/html; charset=UTF-8');
echo '<html><head><title>Hello World</title></head><body>Hello world!</body></html>';
Save the file under C:\inetpub\wwwroot\index.php using the UTF-8 format (without BOM).
Then open your brand new website using your browser on this address: http://localhost/index.php