Windows Server

How to install PHP on Windows Server


PHP (recursive acronym for PHP: Hypertext Preprocessor) is a widely-used open source general-purpose scripting language that is especially suited for web development and can be embedded into HTML.

I will follow the installation steps of the PHP Non Thread Safe version on a Windows Server 2019 Standard Evaluation (Desktop Experience) operating system what needs IIS and CGI to be installed. Install first the IIS (Internet Information Services) by opening Server Manager where we have Manage, Tools, View and Help menus. At Manage we click on Add Roles and Features and for IIS installation on Server Roles select Web Server (IIS), then Add Features and Next after selecting. At Role Services, expand Application Development and select CGI (Common Gateway Interface). We still have a final Next and then Install.

The second step is to download and install Microsoft Visual C++ Redistributable Package by going to the latest supported Visual C++ downloads and download the latest version of the Microsoft Visual C++ 2015-2019 Redistributable (x64) – (x64: vc_redist.x64.exe) and install it;

After adding these roles, features and installing Microsoft Visual C++ Redistributable Package we can start installing PHP Non Thread Safe version for a web server:

  1. We are going to the PHP website at, where we have to download the x64 Non Thread Safe Zip version;
  2. Right-click on the .zip file, select Extract All… and at Select a Destination and Extract File, Files will be extracted to this folder choose C:\php and click Extract;
  3. From C:\php search the file php.ini-production then right-click to Edit with Notepad or Notepad++;
  4. Use Ctrl+F to find

;cgi.force_redirect = 1 and replace with cgi.force_redirect = 0

;fastcgi.impersonate = 1 with fastcgi.impersonate = 1

;extension_dir = "ext" with extension_dir = "C:\php\ext"

  1. Save the changes and create a new file through File\Save as… (Ctrl+Alt+S) and instead of php.ini-production change with php.ini;
  2. Open Internet Information Services (ISS) Manager through Start\Windows Administrative Tools or Server Manager\Tools\Internet Information Services (ISS) Manager;
  3. Find Handler Mapping, and at Actions\Open Feature, Actions\Add Module Mapping… ;

Request path: *.php

Module: FastCGIModule

Executable: C:\php\php-cgi.exe

Name: PHP with FastCGI

  1. Click OK and Yes to confirm adding the module mapping;
  2. At Internet Information Services (ISS) Manager we will open and configure the FastCGI Settings by Actions\Open Feature or double-click on the icon;
  3. Select or double-click on C:\php\php-cgi.exe from Use this feature to configure FastCGI applications used by websites on this server and from Actions click Edit;
  4. The Edit FastCGI Application was opened and at FastCGI Properties under General\Environment Variables (Collection) click on the three dots
  5. Under Members click Add and for the Name Properties we change Name: PHP_MAX_REQUESTS and VALUE: 5000 then click OK to save the changes;
  6. OK to exit from Edit FastCGI Application and come back to the FastCGI Settings and we can close Internet Information Services (ISS) Manager;
  7. To restart IIS open the Comand Prompt or PowerShell and type iisreset


Attempting stop...
Internet services successfully stopped
Attempting start...
Internet services successfully restarted

  1. Still on Command Prompt/PowerShell change directory (cd c:\php) to C:\php and type php –info where a long list of information will be displayed. This means that PHP is workable;
  2. You can go to the C:\inetpub\wwwroot directory and create info.php file and insert the <?php phpinfo(); ?> code;
  3. Open your favorite browser and type http://localhost/info.php where you should see the PHP information page;
  4. To update to a newer PHP version, make a backup of the php.ini, delete the C:\php folder and extract like in step 2 the new .zip version, then copy the php.ini file in C:\php. But if there are only a few lines to change, you can repeat steps 4 and 5.

You can find the latest version of PHP at through the Download menu.