How To Manually Install PHP 7.1 for Windows Server 2016

Motivation:

To understand how PHP works with IIS in order to be able to update PHP to any version to address compatibility or security issues.

Using a tool to install PHP for IIS, for example Microsoft Web Platform Installer 5.0 https://www.microsoft.com/web/downloads/platform.aspx, restricts us from using only versions supported by the tool.

Solution:

  • Install CGI for IIS.
  • Download VC14 x86 Non Thread Safe under PHP 7.1 section from http://windows.php.net/download/
  • Extract the ZIP file to C:\Program Files\php-7.1.15-nts-Win32-VC14-x86 folder.
  • Rename the php-.ini-development file to php.ini.
  • Open the php.ini file and add the following line at the end of the file.
extension=php_wincache.dll
  • Uncomment the following lines
fastcgi.impersonate = 1;

cgi.fix_pathinfo=1;
cgi.force_redirect = 1 (and change the value to 0, i.e. cgi.force_redirect = 0)

extension_dir = "C:\Program Files\php-7.1.15-nts-Win32-VC14-x86\ext"

extension=php_curl.dll
extension=php_mbstring.dll
extension=php_mysqli.dll
extension=php_pdo_mysql.dll
extension=php_openssl.dll

error_log = "C:\Program Files\php-7.1.15-nts-Win32-VC14-x86\php_errors.log"

error_log = syslog
  • Add C:\Program Files\php-7.1.15-nts-Win32-VC14-x86 to System Path.
  • Download x86 package of WinCache 2.0 for PHP 7.1  from https://www.iis.net/downloads/microsoft/wincache-extension
  • Extract and copy the php.wincache.dll file to C:\Program Files\php-7.1.15-nts-Win32-VC14-x86\ext
    folder.
  • Open IIS, click on Server name, double click on Handler Mappings > Add Module Mapping with below information
Request path = *.php
Module = FastCgiModule
Executable = "C:\Program Files\php-7.1.15-nts-Win32-VC14-x86\php-cgi.exe", Name = PHP7.1
Request Restrictions = File or folder
<?php
phpinfo();
?>

Open a Command Prompt, execute below command and ensure that no warnings appear.

php -version

How to Remove Microsoft .NET Framework

Problem:

Some applications do not work with the latest Microsoft .NET Framework. You need to remove it and install an older version of Microsoft .NET Framework.

Solution:

1. Use below utility to remove the current Microsoft .NET Framework.

.NET Framework Cleanup Tool

2. Download an appropriate version of Microsoft .NET Framework using one of below links and install it.

3. Use below utility to detect the installed Microsoft .NET Framework versions.

.NET Detector