[PHP] Install PHP on Windows with IIS

##PHP Installation and Configuration##

Extract PHP

Extract your PHP ZIP file to your desired location. Most people recommend C:\php but it can be anywhere you like. It is best to keep the path short. In this case, I wanted my installation in D:\SITES\php … here is a partial list of the files that you should see - there are many more than this however…


Run the VC++ 11 Redistributable installer ( vcredist_x86.exe )

This is required by PHP. You must install this for anything to work.


Edit your PHP configuration file ( php.ini )

These are some of the settings in the configuration file that you should set:

; PHP's default character set is set to empty.
; http://php.net/default-charset
default_charset = "UTF-8"

; Directory in which the loadable extensions (modules) reside.
; http://php.net/extension-dir
; extension_dir = "./"
; On windows:
; extension_dir = "ext"
extension_dir = "D:\SITES\php\ext"

; cgi.force_redirect is necessary to provide security running PHP as a CGI under
; most web servers.  Left undefined, PHP turns this on by default.  You can
; turn it off here AT YOUR OWN RISK
; **You CAN safely turn this off for IIS, in fact, you MUST.**
; http://php.net/cgi.force-redirect
cgi.force_redirect = 0

; FastCGI under IIS (on WINNT based OS) supports the ability to impersonate
; security tokens of the calling client.  This allows IIS to define the
; security context that the request runs under.  mod_fastcgi under Apache
; does not currently support this feature (03/17/2002)
; Set to 1 if running under IIS.  Default is zero.
; http://php.net/fastcgi.impersonate
fastcgi.impersonate = 1

[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
;date.timezone =
date.timezone = "Canada/Saskatchewan"

;;;;;;;;;;;;;;;;;;;;;;
; Dynamic Extensions ;
;;;;;;;;;;;;;;;;;;;;;;

; If you wish to have an extension loaded automatically, use the following
; syntax:
;
;   extension=modulename.extension
;
; For example, on Windows:
;
;   extension=msql.dll
extension=php_sqlsrv_56_nts.dll
extension=php_pdo_sqlsrv_56_nts.dll

Create a phpinfo file ( phpinfo.php )

This file will allow us to test that PHP is running correctly.

Create a text file and place the following code inside it. Save it as phpinfo.php

<?php
echo date("Y-m-d H:i:s");
phpinfo();
?>

Place the file in your root web folder. By default, the path will be:

C:\inetpub\wwwroot\

1 Like