Installing PHP is relatively simple. Follow the steps in this guide to install PHP version 8 on a Windows operating system (I am using Windows 10). These instructions are for a dev box; no considerations have been made for security. You will typically be doing this as part of the process of setting up a WAMP dev box which is discussed in the WAMP (&LAMP) tutorial.
In this post:
Required knowledge:
Not installed
If PHP is installed, there will be a PHP directory (most likely on the root).
cmd prompt

- Open the command prompt in the php directory
- Enter the command PHP -version
Browser

- Open a PHP file in your browser
- The script is output as plain text instead of being processed
Download
- Download PHP from its official website.
- Select and download the .zip file from the respective section depending on your system architecture (x86 or x64).
- For Windows 10 select php-8.2.4-Win32-vs16-x64.zip
Install
- Extract the .zip file
- Move the resulting folder — php-8.2.4-Win32-vs16-x64 — to your C-drive
- Rename the folder to php (i.e. C:\php).
PATH
Add the folder (C:\php) to the Environment Variable Path so that it becomes accessible from the command line:
- Right-click on My Computer or This PC icon, then select Properties from the context menu.
- Then click the Advanced system settings link, and then click Environment Variables.
- In the section System Variables, we must find the PATH environment variable and then select and Edit it.
- If the PATH environment variable does not exist, click New.
- In the Edit System Variable (or New System Variable) window, specify the value of the PATH environment variable (
C:\php
or the location of our extracted php files). - Close all remaining windows by clicking OK.
Installed

- Open the command prompt to the PHP directory
- Enter the command: PHP -version
At this stage, you can run PHP locally from the command prompt. If that is your aim, head on over to “Hello World!” with PHP CLI. However, if you want to use PHP on a web page, read on.
Web
If you are setting up an environment for web development, you will most likely already have installed Apache HTTP Server. You will then need to configure Apache and PHP. Before you do that, it may be a good idea to run PHP’s built-in web server as a test. For this tutorial, I will assume you installed Apache at the following location: C:\Apache24
Create a simple index.php in your htdocs folder (C:\Apache24\htdocs); the following will do:
<?php echo "Hello World!";
The syntax of the command to type at the command prompt to start the web server up is as follows:
php -S localhost:port -t your_folder/
If you have a standard set-up, the command will be:
php -S localhost:8000 -t C:/apache24/

Open your browser and enter localhost into the address bar.
Apache configuration
The final step is to configure Apache. Before Apache sends a web page to the client it checks to see if there is any PHP code that first needs to be processed by the PHP engine. For this to happen, Apache needs to know where the PHP processing module is. This is done by adding some info to the Apache configuration file which is at the following location by default: C:\Apache24\conf\httpd.conf
Open httpd.conf
and paste the following on a new line at the end of the file:
# PHP8 module PHPIniDir "C:/php" LoadModule php_module "C:/php/php8apache2_4.dll" AddType application/x-httpd-php .php
Save and close the config file.
Restart Apache
You will have to restart Apache once you have made and saved changes to your config.

View
Open your browser, type localhost/index.php in the address bar and press Enter.
References:
- GeeksforGeeks. (2019). How to execute PHP code using command line? Available at: https://www.geeksforgeeks.org/how-to-execute-php-code-using-command-line/ (Accessed: 28 March 2023).
- PHP: Hypertext Preprocessor. (no date) PHP For Windows: Binaries and sources Releases. Available at: https://windows.php.net/download/ (Accessed: 10 June 2024).