This post explains all the steps required to install PHP 7 from the official site on Windows 10. The steps should be similar on other versions of Windows.
In some cases, we need to develop or test our application against a specific version of PHP or to install it separately. In such cases, we can download it from the official site instead of using a bundled package in the form of XAMPP or WAMP.
Step 1 - Download PHP
Go to the official download link and download the required version. The distributions are provided as tar and windows binaries. While writing this tutorial, PHP 7.3.1 is the most recent one, hence we will discuss the installation steps specific to PHP 7.3.1. Click on Windows Download link and it will open the page having Binaries and Sources packaged for Windows.
We can see that PHP is available either as Thread Safe and Non Thread Safe. In simple terms, we can use Thread Safe PHP if we are using mod_php as worker MPM in Apache which spans multiple threads concurrently to process the requests and Non Thread Safe can be used for CGI. The Thread Safe version is required for web servers running in a multithreaded context.
The download page also provided binaries for both 32-bit and 64-bit Operating System. We will download the Zip Thread Safe version for 64-bit Operating System having the title as - VC15 x64 Thread Safe. As a regular user, we do not need the Debug Pack which is required for PHP developers.
Step 2 - Extract the Zip
Extract the downloaded zip at a specific location. It will look similar to the one having PHP executable file as shown in Fig 3.
Step 3 - Verify Installation
Open the command prompt and type php --version to check the available version. It will look similar to Fig 4 in case no other PHP versions are available.
We need to configure the environment variable to access PHP from the command line. Please follow below mentioned steps to do so.
Right Click -> My Computer(This PC) -> Properties -> Advanced System Settings
The above steps will open the Windows settings panel as shown in Fig 5.
Now click on Environment Variables, select Path under System Variables section and click on Edit. We need to add a path of installed PHP to the system Path.
Click on New Button and add the path to installed PHP bin which is E:\tools\php\php-7.3.1 in our case. Press OK Button 3 times to close all the windows. This sets the PHP 7 on system environment variables to access the same from the console.
Now again open the console and test the PHP version as shown in Fig 6.
These are the basic steps required to install PHP 7 on Windows 10.