Motivation:
- You want to deploy a PHP application or WordPress on Windows Server 2019.
- You want to update PHP to any version to address compatibility or security issues in Windows.
- You want to understand how PHP works with IIS.
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
- Download and install VC_redist.x86.exe of Microsoft Visual C++ Redistributable for Visual Studio 2019 here or on https://visualstudio.microsoft.com/downloads/#microsoft-visual-c-redistributable-for-visual-studio-2019
- en a Command Prompt, execute below command and ensure that NO WARNINGS APPEAR.
php --version
- Create phpinfo.php file with below content in the root website folder.
<?php phpinfo(); ?>
- Open http://localhost/phpinfo.php URL and verify PHP information.
(Visited 9,241 times, 1 visits today)