Install PHP and use it with IIS
suggest changeFirst 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.
- Download the PHP version you like from http://windows.php.net/download/ and make sure you download the Non-Thread Safe (NTS) versions of PHP.
- Extract the files into
C:\PHP\
. - Open the
Internet Information Services Administrator IIS
. - 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
vcredist_x64.exe
orvcredist_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 theextension_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