Install PHP and use it with IIS

Total Views : 72
Zoom In Zoom Out Read Later Print

getting PHP to run on IIS isn't very hard, and gives you access to all ... The easiest way to install PHP Language on IIS is to use Microsoft's Web.

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.

1. 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.

2. Extract the files into C:\PHP\.

3. Open the Internet Information Services Administrator IIS.

4. Select the root item in the left panel.

5. Double click on Handler Mappings.

6. On the right-side panel click on Add Module Mapping.

7. 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

8. Install vcredist_x64.exe or vcredist_x86.exe (Visual C++ 2012 Redistributable) from https://www.microsoft.com/en-US/download/details.aspx?id=30679

9. Setup your C:\PHP\php.ini, especially set the extension_dir ="C:\PHP\ext".

10. Reset IIS: In a DOS command console type IISRESET.

Optionally you can install the PHP Manager for IIS which is of great help to set up 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

See More

Latest Photos