Save 10%Pay yearly on any plan. 6% half-yearly, 3% quarterly. Help centreWhatsAppTelegram TeamsOpen a ticket

How to Install PHP on Windows 10 and Windows 11

Install PHP on Windows by hand: which download to choose, the php.ini settings that matter, the PATH, a test with the built-in web server, and Composer.

3 min readBy Soumya

Reviewed by the AmazingRDP technical team

Installing PHP on Windows 10

Need a Windows machine that stays online for development or testing? A Windows VPS gives you full admin access. See Windows VPS from $8.99

PHP runs on Windows without any extra software: download a ZIP file, unpack it, change two settings, and it works from the command line with its own small web server. The steps are the same on Windows 10, Windows 11 and Windows Server.

1. Download the right package

Go to windows.php.net/download and pick the newest stable version. Each version is offered in several builds:

BuildChoose it when
x64 Non Thread Safe (NTS)You use PHP from the command line, with its built-in server, with IIS or with Nginx. The right choice for most people
x64 Thread Safe (TS)You load PHP as a module into the Apache web server
x86Only for 32-bit Windows

Download the Zip. PHP also needs Microsoft's free Visual C++ Redistributable (the 2015-2022 x64 package); the download page links to it. Many PCs have it already.

2. Unpack it

Right-click the ZIP, choose Extract All, and extract to C:\php. Avoid folders with spaces in the name.

3. Create php.ini

In C:\php, copy the file php.ini-development and name the copy php.ini. Open it in a text editor and change these lines by removing the semicolon at the start:

extension_dir = "ext"
extension=curl
extension=fileinfo
extension=mbstring
extension=openssl
extension=pdo_mysql
extension=zip

The first tells PHP where its extensions are. The others switch on the extensions that most projects and Composer expect; add more (gd, intl, pdo_pgsql) when a project asks for them. For a server that is open to the internet, start from php.ini-production, which does not show error details to visitors.

4. Add PHP to the PATH

  1. Open the Start menu, type environment and open Edit the system environment variables.
  2. Click Environment Variables.
  3. Under System variables, select Path and click Edit.
  4. Click New, type C:\php, and confirm with OK three times.

Or in PowerShell opened as administrator:

[Environment]::SetEnvironmentVariable("Path", $env:Path + ";C:\php", "Machine")

5. Test

Open a new terminal window (open ones do not see the changed PATH):

php -v
php --ini
php -m

The first shows the version, the second which php.ini is loaded, the third the active extensions.

6. Run a page

Create a folder such as C:\sites\test with a file index.php:

<?php
echo "PHP " . PHP_VERSION . " works";

Start PHP's built-in web server in that folder:

cd C:\sites\test
php -S localhost:8000

Open http://localhost:8000 in a browser. Stop the server with Ctrl + C. The built-in server is for development only; a public site belongs behind IIS, Nginx or Apache.

7. Composer

Composer installs PHP libraries and is needed for Laravel, Symfony and most modern projects. Download Composer-Setup.exe from getcomposer.org and run it; it finds C:\php\php.exe by itself. Check with composer --version.

Errors and their causes

MessageCause
'php' is not recognized as an internal or external commandThe PATH entry is missing or the terminal was opened before the change
VCRUNTIME140.dll was not foundThe Visual C++ Redistributable is not installed
Unable to load dynamic libraryextension_dir is still commented out, or the extension does not exist in C:\php\ext
Loaded Configuration File: (none)The file is still called php.ini-development, or is in another folder

Other ways to get PHP on Windows

  • A bundle such as XAMPP or Laragon installs PHP together with a web server and a database in one step. Good for a quick start.
  • WSL gives you a real Linux inside Windows, where PHP behaves as it will on most web servers. See how to enable WSL.

For a Windows machine that stays online for testing, see our Windows VPS plans. Related: XAMPP on Ubuntu, install GitHub CLI on Windows and running .ps1 files with PowerShell.

Questions

Which PHP version should I download for Windows?

The newest stable version in the x64 Non Thread Safe build, unless you load PHP as a module in Apache; then take Thread Safe.

Why is php not recognized in the command prompt?

The PHP folder is not in the PATH, or the terminal was opened before you added it. Add it and open a new window.

Do I need Apache or IIS to run PHP on Windows?

Not for development. php -S localhost:8000 starts PHP's built-in web server.

Where is php.ini on Windows?

In the PHP folder, for example C:\php\php.ini. php --ini shows which file is loaded.