In this article, we will learn how to install PHP on Windows Server. There are several ways to install PHP, including Microsoft's PHP Manager for IIS, but we will focus on a universal installation method that allows you to install PHP even without being tied to, for example, IIS. Integrating PHP and IIS is not difficult.
PHP variants for each version of PHP
There are two PHP variants for each version of PHP: Non Thread Safe and Thread Safe
Thread Safe - thread safe. Select this option if PHP is used as mod_php (Apache module). In most cases, in conjunction with the IIS web server, the Thread Safe option is not suitable for the Windows Server operating system.
Non Thread Safe is a non-thread safe version of PHP. Used in cases where PHP is run via CGI and each thread is a separate CGI process isolated from others and there is no need for thread safety. At the same time, the request processing speed is higher. Non Thread Safe should also be selected if you plan to use FastCGI. Just this mode of operation is recommended to be used in the work of IIS + PHP.
To install PHP of the required version, go to the PHP for Windows download page and download the zip archive VS16 x64 Non Thread Safe of the PHP version we need. In this example, we will use PHP8.1
Next, create a folder on the server disk into which you need to unzip the downloaded archive. For example C:\php
In addition, PHP requires the Microsoft Visual Studio package to run on Windows.
Since we chose the VS16 x64 version, on the same page of the site there is a link to download the required version of Microsoft Visual Studio, namely Visual Studio 2015-2019
Download and install: During installation, do not change the proposed settings and wait for completion.
Additionally, it is recommended to set the path to PHP in the global PATH variable. To do this, open the System Properties window: Start - Run and execute the command
control system
Next, open the Advanced sysytem setting window - Advanced tab - click the Environment Variables button
:Add the path to the folder where PHP is located in the value of the PATH variable. In our case, this is the C:\php folder; (be sure to put a semicolon after the specified path)
Save the changes by clicking OK one by one in the open windows.
How to check the installed version of PHP
To find out the installed version of PHP, in the command line window, run the command
php -v
In this case, there is no need to change to the C:/php directory, since the path to the PHP executable file was previously added to the environment variables.
In this article, we learned how to install PHP of the required version on Windows Server.
We also suggest you other useful articles: