Table of Contents
You typed php -v and Windows answered: “php is not recognized as an internal or external command.” Frustrating, right?
Don’t worry. Installing PHP on Windows has only a few steps, and the hard part is just knowing which file to download and where to click. In this guide you will install PHP 8.5, add it to your PATH, and run your first PHP script, with a picture for every step.
What you will have at the end (about 10 minutes):
✓ PHP 8.5 installed in C:\PHP
✓ php working from any folder in Command Prompt
✓ A working php.ini with the common extensions on
✓ Your first PHP script and a local web server running
Quick Roadmap
Before you start: PHP for Windows needs the Microsoft Visual C++ Redistributable (2015-2022, x64). Most PCs already have it. If you later see an error about VCRUNTIME140.dll, install it from Microsoft and try again.
Download PHP 8.5 for Windows
Open windows.php.net/download. This is the official site for Windows builds of PHP, so you can trust it. Scroll down to the PHP 8.5 section.
You will see several options, and this is where beginners get confused. Here is the simple rule:
| Option | Should you pick it? |
|---|---|
| x64 | Yes. Almost every modern Windows PC is 64-bit. |
| Non Thread Safe | Yes, this is the right choice for this guide. It is what you want for the command line and PHP’s built-in server. |
| Thread Safe | Only if you plan to use Apache with mod_php. It is not wrong for beginners, just not needed here. |
| Debug Pack / Development package | No. These are for people building PHP extensions. |
Example layout. Click the plain Zip link, not the Debug Pack.
Click Zip and let it download. It is around 33 MB.
Tip: The real page also shows a SHA256 code next to each file. You can compare it with your download to be sure the file is genuine. This is optional for beginners, but it is a good habit.
Extract PHP to C:\PHP
We will keep PHP in a short, simple folder: C:\PHP. A short path is easy to remember and avoids problems with spaces in folder names.
Open C:\PHP. You should see php.exe directly inside, not inside another folder.
If you see a PHP folder inside your PHP folder, move the files up one level.
STEP 3Create and Edit php.ini
PHP reads its settings from a file called php.ini. The download comes with two templates but no real php.ini, so we make one.
Can’t see “.ini” in the name? In File Explorer, click View → Show → File name extensions. Otherwise you may accidentally create php.ini.txt, which PHP will ignore.
In php.ini, a line that starts with a semicolon ; is switched off. Removing the semicolon switches it on. Use Ctrl + F to find these lines and remove the semicolon in front of each:
; BEFORE (switched off) ;extension_dir = "ext" ;extension=curl ;extension=fileinfo ;extension=mbstring ;extension=openssl ; AFTER (switched on) extension_dir = "ext" extension=curl extension=fileinfo extension=mbstring extension=openssl
Only delete the semicolon. Leave everything else on the line exactly as it is.
What do these do? extension_dir tells PHP where its add-ons live. curl lets PHP talk to other websites and APIs, mbstring handles text in any language, openssl enables secure connections, and fileinfo detects file types. Most projects and Composer need them.
Save the file with Ctrl + S.
STEP 4Add PHP to the Windows PATH
This is the most important step. PATH is a list of folders Windows checks when you type a command. Adding C:\PHP to it means you can type php from any folder.
Your list will have different entries. Just add C:\PHP at the end and do not delete anything.
Careful: Do not delete or change the existing lines in Path. Only add a new one. Also, make sure you type C:\PHP with no spaces and no extra characters at the end.
Test PHP 8.5
Now close every Command Prompt or PowerShell window and open a brand-new one. This matters: windows that were already open do not know about the new PATH.
Type this and press Enter:
php -v
If it worked, you will see something like this:
C:\Users\You> php -v PHP 8.5.x (cli) (built: ...) ( NTS Visual C++ 2022 x64 ) Copyright (c) The PHP Group Zend Engine v4.5.x, Copyright (c) Zend Technologies
Your exact version numbers may differ slightly. Seeing “PHP 8.5” means success.
Want to double check that your php.ini is being used and your extensions loaded? Run these two commands:
php --ini php -m
php --ini should show C:\PHP\php.ini as the loaded file, and php -m lists the active extensions, including curl, mbstring, openssl and fileinfo.
Run Your First PHP Script
Create a folder called php-projects, then create a file inside it named test.php with this code:
<?php echo "PHP 8.5 is working on Windows!";
Open Command Prompt inside that folder and run it:
php test.php
C:\php-projects> php test.php PHP 8.5 is working on Windows!
You did it! PHP 8.5 is installed and running on your computer.
Bonus: See PHP in Your Browser
You do not need Apache or XAMPP to start. PHP has a small web server built in. Run this inside your php-projects folder:
php -S localhost:8000
Then open http://localhost:8000/test.php in your browser. You will see your message on the page. Press Ctrl + C in the terminal to stop the server.
Troubleshooting: If Something Goes Wrong
| Problem | How to fix it |
|---|---|
| “php is not recognized” | Open a new Command Prompt. If it still fails, re-check that C:\PHP is in the System Path and that php.exe is directly inside it. |
| VCRUNTIME140.dll was not found | Install the Microsoft Visual C++ Redistributable 2015-2022 (x64), then try again. |
| “Unable to load dynamic library” | Check that extension_dir = "ext" has no semicolon, and that you only removed the semicolon on real extension lines. |
| php –ini shows “Loaded Configuration File: (none)” | Your file may be named php.ini.txt. Show file extensions and rename it to php.ini. |
| Windows blocks the files | Right-click the ZIP, choose Properties, tick Unblock, then extract again. |
Common Questions
Should I use Thread Safe or Non Thread Safe?
For the command line and PHP’s built-in server, use Non Thread Safe. Choose Thread Safe only if you plan to run PHP as an Apache module. Both work for learning, but Non Thread Safe is the simpler default.
Do I need XAMPP or Laragon instead?
No. XAMPP and Laragon install PHP, Apache and MySQL together in one click, which is handy later. Installing PHP by hand, like in this guide, teaches you how it actually works and gives you a clean setup.
How do I update PHP later?
Download the new ZIP, extract it over a fresh folder, copy your php.ini across, and keep the same PATH entry. Always keep your old folder until the new one works.
Can I use development settings on a live website?
No. php.ini-development shows errors on screen, which is great for learning but unsafe on a live site. For production, start from php.ini-production.
Final Thoughts
That’s it. You downloaded PHP 8.5, extracted it to C:\PHP, set up php.ini, added it to your PATH, and ran your first script. Every PHP developer on Windows starts with these exact steps.
Next up: connecting a local web server like Apache and building real pages. Subscribe so you don’t miss it, and tell me in the comments if you got stuck anywhere. I will help you.
Watch the Full Video Tutorial
Prefer to follow along on screen? I walk through every step in the video below, so you can pause and copy exactly what I do.
▶ Watch on YouTube Subscribe to the Channel
If this guide helped you, share it with a friend who is starting PHP. Thank you for reading!


