Tag Archives: Server 2019

How to Manually Install PHP 7.4 for Windows Server 2019

Motivation:

You want to understand how PHP works with IIS.

You want to prepare a PHP or WordPress development environment in Windows.

You want to update PHP to any version to address compatibility or security issues in Windows.

You may use Microsoft Web Platform Installer to install PHP for IIS. However the tool may restrict you from using only the supported versions.

Solution:

  • Install CGI for IIS on Turn Windows features on or off > Internet Information Services > World Wide Web Services > Application Development Features > CGI.
  • Download VC15 x86 Non Thread Safe package here or under PHP 7.4 section from http://windows.php.net/download/
  • Extract the ZIP file to the C:\Program Files (x86)\php-7.4.9-nts-Win32-vc15-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.4.9-nts-Win32-vc15-x86\ext"

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

error_log = "C:\Program Files (x86)\php-7.4.9-nts-Win32-vc15-x86\php_errors.log"

error_log = syslog
  • A sample php.ini file can be download here.
  • Add C:\Program Files (x86)\php-7.4.9-nts-Win32-vc15-x86 to System Path.
  • Download x86 package of WinCache 2.0 for PHP 7.4 here or from https://sourceforge.net/projects/wincache/.
  • Extract and copy the php_wincache.dll file to C:\Program Files (x86)\php-7.4.9-nts-Win32-vc15-x86\ext
    folder.
  • Open IIS, click on Server name, double click on Handler Mappings, click on Add Module Mapping, and enter below information
Request path = *.php
Module = FastCgiModule
Executable = "C:\Program Files (x86)\php-7.4.9-nts-Win32-vc15-x86\php-cgi.exe"
Name = PHP 7.4
Request Restrictions = File or folder
php --version
    • Create phpinfo.php file with below content in the root website folder.
    <?php 
    phpinfo(); 
    ?>