Install PHP on Windows in Three Steps, and Run Your First Script
The short way to get PHP working on Windows: download, unpack, add to the PATH. Then run a script, start the built-in web server and use the interactive shell.
2 min readBy Daniel
Reviewed by the AmazingRDP technical team

Want a Windows machine that stays online for your PHP projects? A Windows VPS gives you full admin access. See Windows VPS from $8.99
PHP needs no installer on Windows. Three steps put it on the machine, and a few commands show that it works. This is the quick version. For the choice between builds, the php.ini settings, Composer and a table of errors, see the full guide: how to install PHP on Windows 10 and 11.
Step 1: download
Open windows.php.net/download and download the Zip of the newest version, in the build x64 Non Thread Safe. That build is right for the command line, the built-in web server, IIS and Nginx. Only if you will load PHP into Apache as a module do you need the Thread Safe build.
Step 2: unpack
Right-click the ZIP file, choose Extract All, and extract to C:\php. In that folder, copy php.ini-development and name the copy php.ini.
Step 3: add PHP to the PATH
Open PowerShell as administrator and run:
[Environment]::SetEnvironmentVariable("Path", $env:Path + ";C:\php", "Machine")
Close the window and open a new one, so that it picks up the change. Check:
php -v
A version number means PHP is installed. If Windows complains about a missing VCRUNTIME140.dll, install Microsoft's Visual C++ Redistributable (x64), which the download page links to, and try again.
A quicker way: winget
Windows 10 and 11 include the package manager winget, which can do all three steps. Search for the current package name and install it:
winget search PHP
winget install PHP.PHP.8.4
The number in the name follows the PHP version; use the one the search shows. Open a new terminal afterwards.
Run your first script
Create a file hello.php in any folder:
<?php
echo "Hello from PHP " . PHP_VERSION . PHP_EOL;
Run it from that folder:
php hello.php
One-liners and the interactive shell
php -r "echo PHP_VERSION;"
php -a
The first runs a line of PHP without a file. The second opens an interactive prompt where each line you type is run at once: a good place to try a function. Leave it with exit.
See a page in the browser
PHP has a small web server built in. In a folder with an index.php:
php -S localhost:8000
Open http://localhost:8000. Stop the server with Ctrl + C. It is meant for development; a public site belongs behind IIS, Nginx or Apache.
Useful checks
| Command | Shows |
|---|---|
php --ini | Which php.ini is loaded |
php -m | The active extensions |
php -i | Every setting (long) |
php -l file.php | Whether a file has syntax errors, without running it |
What comes next
- Extensions. A project that needs a database or web requests wants a few lines switched on in
php.ini. The full guide lists them. - Composer, for installing libraries and frameworks such as Laravel.
- A database. A bundle such as XAMPP brings PHP, a web server and MariaDB together; on Linux, see XAMPP on Ubuntu.
- A machine that stays on. The steps are identical on Windows Server: see our Windows VPS plans.
Questions
What is the quickest way to install PHP on Windows?
Download the ZIP from windows.php.net, extract it to C:\php and add that folder to the PATH. Or use winget.
How do I run a PHP file on Windows?
Open a terminal in the file's folder and run php file.php.
How do I check that PHP is installed?
Run php -v in a new terminal window. It prints the version.
Can I test a PHP website without Apache?
Yes. Run php -S localhost:8000 in the site's folder and open that address in a browser.