How to Manually Install PHP 8.1 on Windows 10

Motivation:

  • You want to understand how PHP works with IIS.
  • You want to prepare a PHP or WordPress development environment on Windows.
  • You want to update PHP to any version to address compatibility or security issues on Windows.

Solution:

  • Install CGI for IIS on Turn Windows features on or off > Internet Information Services > World Wide Web Services > Application Development Features > CGI.
  • Download VS16 x64 Non Thread Safe package under PHP 8.1 section on https://windows.php.net/download/.
  • Extract the ZIP file to C:\Program Files\php-8.1.10-nts-Win32-vs16-x64 folder.
  • Download the cacert.pem file and move it to the C:\Program Files\php-8.1.10-nts-Win32-vs16-x64\extras\ssl folder.
  • Copy the php-.ini-development file to php.ini.
  • Open the php.ini file and 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-8.1.10-nts-Win32-vs16-x64\ext"
    
    extension=curl
    extension=fileinfo
    extension=gd
    extension=gettext
    extension=mbstring
    extension=exif ; Must be after mbstring as it depends on it
    extension=mysqli
    extension=openssl
    extension=pdo_mysql
    
    error_log = "C:\Program Files\php-8.1.10-nts-Win32-vs16-x64\php_errors.log"
    
    error_log = syslog
    
    curl.cainfo = "C:\Program Files\php-8.1.10-nts-Win32-vs16-x64\extras\ssl\cacert.pem"
    
    openssl.capath="C:\Program Files\php-8.1.10-nts-Win32-vs16-x64\extras\ssl\cacert.pem"
  • Add C:\Program Files\php-8.1.10-nts-Win32-vs16-x64 to SYSTEM PATH.
  • Restart your machine.
  • Open cmd and execute the command below to ensure that the PHP file can be found in the SYSTEM PATH.
    php --version
  • 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-8.1.10-nts-Win32-vs16-x64\php-cgi.exe"
    
    Name = PHP 8.1
    
    Request Restrictions = File or folder
  • Create phpinfo.php file with below content in the root website folder.
    <?php phpinfo(); ?>

 

 

(Visited 7,440 times, 1 visits today)

Leave a Reply