You can install PHP on a Windows machine in multiple ways. It all depends on your needs/requirements.
XAMPP and WampServer are great for beginners or people that want to build something really quick and have less experience with PHP and Apache environments. By installing them you get a ‘ready to go’ development environment that includes: PHP, Apache, MySQL and more…
In most cases though, you might just be interested to install just PHP, to use it in different development environments. Below I will show you step by step what you have to do to install PHP 7.2 on a Windows machine.
- How to install PHP on Windows?
- Test PHP is installed
- What extensions do I need?
- How to enable extensions?
- Check what PHP extensions you have installed
- How to start a localhost on Windows
- Conclusion
How to install PHP on Windows?
First, go and download PHP 7.2 .zip file from here. Choose the version you need for your machine, x64 or x86. I usually install the Non Thread Safe version.
Read this for more info about What is thread safe or non-thread safe in PHP?

Choose where you want to install PHP and make a new folder called PHP. I usually install it in /C.

Export the php zip contents into the /PHP folder you have just made.

Go into the /PHP folder, make a copy of the php.ini-development file (literally, copy and past that file again into the folder). Rename the file you just copied to php.ini.

Open php.ini file in any code editor and search (ctrl + f) for extension_dir = “ext”. Uncomment that line by removing the semicolon, as below:

Open Environment Variables (Windows Search for ‘env’) and open Edit the system environment variables. Click Environment Variables.

Under System Variables, select PATH and click Edit.

Add two new entries in that variables list. Click New and add the location of your /PHP folder (C:\PHP) in my case. Next, add the location of your extension folder (C:\PHP\ext) in my case. Click OK.

Under System Variables click New and add PHPRC for the name and C:\PHP for the value of this new system variable. Click OK and then OK again.

The next thing you want to do is to reboot/restart your computer.
Test PHP is installed
Once your machine restarted, the simplest way to check if PHP was installed correctly is to:
Open cmd by windows searching for cmd. This will open your terminal.

Run php -v and you should see a similar output, depending on the version of PHP you have installed.

You can also run php -i for a lot more information about the PHP you have installed or create a index.php file on your localhost containing the following code:
<?php echo phpinfo(); ?>

What extensions do I need?
You don’t need all the extensions to be enabled. Every developer will use different extensions, based on what they develop. Here is a good resource when it comes PHP extensions.
There are a few basic extensions that you will need to enable though:
- Depending on what database service you want to use, enable pdo_sqlite; pdo_mysql or pdo_pgsql.
- Enabling curl and mbstring is also something I usually do.
How to enable extensions?
Open php.ini in any code editor and search (ctrl + f) for ‘;extension=curl’. Or just scroll down until you see the list below:

NOTE**: Make sure you enable openssl as well.
Uncomment the extensions you wish to enable and save the file.
Check what PHP extensions you have installed
In your terminal (cmd) run the following command. That will show you what modules/extensions you have enabled and loaded.
php -m
or
php -r "print_r(get_loaded_extensions());"

How to start a localhost on Windows
Open terminal (cmd) and cd (go to) the folder where you want to start the localhost. This is usually project folder or where your index.php file is located.
Once you’re there, run the following command in the terminal:
php -S localhost:8000
More info from the documentation here.

Check if your localhost works by opening this link into the browser:
Conclusion
As you have probably figured out, installing PHP on Windows is not as hard as it may seem. Just make sure you don’t miss a step along the way and everything should work perfectly fine by the end of this tutorial. If you face any problems or errors, just comment below your error code and I’ll help you through this process.
couldn’t get the install to work…
http://localhost/test.php returned an error
HTTP Error 404.3 – Not Found
The page you are requesting cannot be served because of the extension configuration. If the page is a script, add a handler. If the file should be downloaded, add a MIME map.
cmd returned an error as well:
php – s localhost:8000 said “could not open input file: localhost:8000”
Thanks for the clear and simple explanations! Always appreciated.
Hi, I find problems.
First of all, i didn’t find “Environment Variables” and I can’t do taskes related with it.
Second, in thestep of “How to start a localhost on Windows” I didn’t find “index.php” in my PHP folder, that’s why running the command in terminal dosen’t work!
What should i do?
Really impressed! Everything is very open and very clear clarification of issues. It contains truly facts. Your website is very valuable. Thanks for sharing.
I am continuously getting Not Found message even the .php file is there. I should have been surely missing something. Can you help ?
Hi, yeah I am happy to help. Where did you get up to and what does your console say when you run php -v?
php -v cmd not working i get php is not recognized by external o internal o batch file
PHP is not installed then. Start the process over and make sure you follow each step.let me know if you manage to solve it or if you need more help.
php -v works for me so it looks like I’ve installed PHP correctly.
However I’m not sure of the next step (I’m a complete beginner by the way).
I’ve created an index.php file but am not sure where to save it or how to execute it.
My Tomcat is listening on port 9999 and I have a servlet defined in \WEBINF\web.xml
(which works by the way – it just puts out some text and a random number when called
from the browser)
The way I’m returning the page to the browser is via out.println to build HTML.
However, when the page is returned to the browset everything is shown EXCEPT
out.println(“PHP Info:”);
out.println(“”);
out.println(“Hello, World”);
out.println(“”);
out.println(“Hello, world!”); // says Hello
out.println(“PHP Info:”);
out.println(“”);
out.println(“Request URI: ” + request.getRequestURI() + “”);
etc.
Actually now I’m thinking that the is not being processed server side
(which is where it should be) and is simply passed back to the browser as-is.
How do I actually get the php code to be processed?
Hi Lan! I’m afraid you might have over engineered this…
Once PHP is installed and you can see some output when you run php -v, all you need to do is to:
1. Create a php file inside a folder somewhere.
2. In that file paste:
cd /Documents/MyFolder/etc…)
5. Once you are in that folder, run the following command to start a localhost:
php -S localhost:8000
This will start a localhost on port 8000. Open http://localhost:8000/ in your browser and you should see the php info.
No need to use tomcat for this. Is this making sense and addressing your issue?
Really thanks for this help.
Work perfectly on my setup.
Clear and fast, as i like
Glad you found it useful!
You have missed a step after clicking “edit” on “path” in environmental settings. Clicking edit prompts the user to edit the path. Creating a new path is not possible at that point. Whatever you are trying to advise, it falls apart at that error.
Thanks for pointing that out mate, but I just checked everything again on my machine and it works fine. As shown in the tutorial. Under ‘System variables’ you select ‘Path’ and then click the ‘Edit’ button. Prompts you with another dialogue box called ‘Edit environment variable’. There you add the new ones and so on…
Thanks for your article, it really helped!!
The only problem that I came across was the same mentioned above. I guess this is the difference between Win 7 or 8 and Win 10: in 7 you edit a Path variable by adding a semicolon after the already existing text (I’ve found this info here https://www.google.com/amp/s/www.howtogeek.com/118594/how-to-edit-your-system-path-for-easy-command-line-access/amp/).
Glad you find it useful. That article looks good.