HOW TO: install PHP 7.2 on Windows

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.

  1. How to install PHP on Windows?
  2. Test PHP is installed
  3. What extensions do I need?
  4. How to enable extensions?
  5. Check what PHP extensions you have installed
  6. How to start a localhost on Windows
  7. 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?

Download PHP
Download PHP

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

Create PHP Folder
Create PHP Folder

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

Export zip file to PHP folder
Export zip file to PHP folder

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.

Create php.ini file
Create php.ini file

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:

Set extension directory
Set extension directory

HOW TO: use Git to start a project and commit files

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

Edit environment variables
Edit 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.

Add env variable
Add env variable

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.

Add new system variable
Add new system variable

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.

Open cmd
Open cmd

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

Check php -v
Check php -v

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:


echo phpinfo();

PHP info file on localhost
PHP info file on localhost

How to install PHP, Apache and MySQL on Ubuntu

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:

  1. Depending on what database service you want to use, enable pdo_sqlite; pdo_mysql or pdo_pgsql.
  2. 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:

PHP extensions
PHP extensions

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


php -r "print_r(get_loaded_extensions());"
Check php modules
Check php modules

Top 3 free coding editors

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.

PHP run localhost
PHP run localhost

Check if your localhost works by opening this link into the browser:



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.

Support this blog by subscribing to the newsletter. There will be no spam, just a few emails from time to time.

Yes, I want to support this blog for more awesome content. 

16 thoughts on “HOW TO: install PHP 7.2 on Windows

  1. 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”

  2. 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?

  3. Really impressed! Everything is very open and very clear clarification of issues. It contains truly facts. Your website is very valuable. Thanks for sharing.

  4. I am continuously getting Not Found message even the .php file is there. I should have been surely missing something. Can you help ?

  5. 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(“Hello, World”);
    out.println(“Hello, world!”); // says Hello
    out.println(“PHP Info:”);
    out.println(“Request URI: ” + request.getRequestURI() + “”);

    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?

    1. 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?

  6. 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.

    1. 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…

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.