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 package here or under PHP 7.1 section from http://windows.php.net/download/
- Extract the ZIP file to C:\Program Files (x86)\php-7.1.33-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 (x86)\php-7.1.33-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 (x86)\php-7.1.33-nts-Win32-VC14-x86\php_errors.log" error_log = syslog
- Add C:\Program Files (x86)\php-7.1.33-nts-Win32-VC14-x86 to System Path.
- Download x86 package of WinCache 2.0 for PHP 7.1 here or from https://www.iis.net/downloads/microsoft/wincache-extension
- Extract and copy the php_wincache.dll file to C:\Program Files (x86)\php-7.1.33-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 (x86)\php-7.1.33-nts-Win32-VC14-x86\php-cgi.exe" Name = PHP 7.1 Request Restrictions = File or folder
- Download and install vc_redist.x86.exe of Microsoft Visual C++ 2015 Redistributable Update 3 RC here or from https://www.microsoft.com/en-us/download/details.aspx?id=52685
- Open a Command Prompt, execute below command and ensure that NO WARNINGS APPEAR.
php -version
- Create phpinfo.php file with below content in the website folder and test the result.
<?php phpinfo(); ?>