Easy steps to install PHP on Windows Server 2016

This tutorial was create for Windows Server 2016 x64, but you can do it on Windows Workstation x86, but you just need to use x86 everywhere.

#

REQUIREMENTS#

  • Windows Server 2016
  • IIS
  • PHP bin files
  • WinCache
  • VC++

IIS service with CGI extension.#

Before to install, verify if you already have it.

1
2Get-WindowsFeature web-cgi

Powershell command to install

1
2Install-WindowsFeature -name web-server,web-cgi –IncludeManagementTools

Installing PHP#

Download PHP version you want to install.

http://windows.php.net/download/

Extract file to C:\Program Files\php

Select PHP configuration to use#

You have 2 configuration files:

  • php.ini-development
  • php.ini-production

You must rename the file configuration to php.ini.

Add Wincache configuration#

Open php.ini file and add this line in the end:

extension=php_wincache.dll

Add PHP path on Environment variables#

On Explorer click properties on This PC

Click on Advanced system settings

Click on Advanced \ Environment Variables

On System variables, edit variable : Path

Add new path. ( C:\Program Files\php )

Install WinCache Extention#

https://www.iis.net/downloads/microsoft/wincache-extension

Download and extract it.

Copy files to folder : C:\Program Files\php\ext

  • php_wincache.dll
  • php_wincache.pdb       (optional)

Configurate PHP in IIS

In IIS open Handler Mappings

Add Module Mapping

  • Request path : *.php
  • Module : FastCgiModule
  • Executable (optional) : C:\Program Files\php\php-cgi.exe
  • Name : PHP

Click on Request Restriction…

Select “FIle or Folder”

Installing VC++#

https://support.microsoft.com/en-ca/help/2977003/the-latest-supported-visual-c-downloads

Just install it.

Verify if it works.

Open the default web site path, root, and create a file <phpinfo.php> with this line:

<?php  phpinfo(); ?>

Usually it is this path: C:\inetpub\wwwroot

Open in your local server this page:

http://localhost/phpinfo.php