First of all you need to have IIS (Internet Information Services) installed and running on your machine; IIS isn't available by default, you have to add the characteristic from Control Panel -> Programs -> Windows Characteristics.
C:\PHP\
.Internet Information Services Administrator IIS
.Handler Mappings
.Add Module Mapping
.Request Path: *.php
Module: FastCgiModule
Executable: C:\PHP\php-cgi.exe
Name: PHP_FastCGI
Request Restrictions: Folder or File, All Verbs, Access: Script
Install vcredist_x64.exe
or vcredist_x86.exe
(Visual C++ 2012 Redistributable) from https://www.microsoft.com/en-US/download/details.aspx?id=30679
Setup your C:\PHP\php.ini
, especially set the extension_dir ="C:\PHP\ext"
.
Reset IIS: In a DOS command console type IISRESET
.
Optionally you can install the PHP Manager for IIS which is of great help to setup the ini file and track the log of errors (doesn't work on Windows 10).
Remember to set index.php
as one of the default documents for IIS.
If you followed the installation guide now you are ready to test PHP.
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