How to install PHP on Windows

To install PHP on Windows you download a zip archive from php.net: there is no installer, you unpack it and tell Windows where it is. This guide is for Windows 11 and works the same on Windows 10. It sets up PHP for the command line, the built-in web server and Composer, which is what a local project needs.

Which PHP build to download

Open https://www.php.net/downloads.php?os=windows. Each PHP version has several zips, and the names tell them apart:

  • x64: for 64-bit Windows, which is almost every PC today. php.net has no builds for ARM processors.
  • Non Thread Safe (NTS): for the command line, the built-in server, Composer and FastCGI (IIS, Nginx). Take this one if you are not sure.
  • Thread Safe (TS): only for running PHP as an Apache module.

So for local development, download VS17 x64 Non Thread Safe of the newest version, PHP 8.5 at the time of writing. The file is called like php-8.5.11-nts-Win32-vs17-x64.zip.

Unpack PHP and create php.ini

PHP needs the Microsoft Visual C++ Redistributable. Many programs have installed it already. If not, get vc_redist.x64.exe from https://aka.ms/vs/17/release/vc_redist.x64.exe (the link from php.net) or install it with winget:

winget install --id Microsoft.VCRedist.2015+.x64 -e

Right-click the downloaded zip, choose Extract All and extract to C:\php, so that php.exe lies directly in C:\php. Then make the settings file from the development template. php.ini-development shows errors on the page, which you want on your own PC. php.ini-production hides them and is meant for servers.

Copy-Item C:\php\php.ini-development C:\php\php.ini notepad C:\php\php.ini

Turn on curl, mbstring, openssl and other extensions

The extensions are already in C:\php\ext, but turned off: in php.ini their lines start with ;. In Notepad, find each line below with Ctrl-F and delete the ; in front of it. The full path in extension_dir lets PHP find the extensions from any folder.

C:\php\php.ini
extension_dir = "C:\php\ext" extension=curl extension=fileinfo extension=mbstring extension=openssl extension=pdo_mysql extension=zip

Save the file. pdo_mysql is for MySQL and MariaDB. For PostgreSQL turn on pdo_pgsql, for SQLite pdo_sqlite. Composer needs openssl and works faster with zip.

Add PHP to PATH and check php -v

  1. Click Start, type environment variables and open Edit environment variables for your account.
  2. Under User variables for <your name>, select Path and click Edit.
  3. Click New, type C:\php and click OK in both windows.

Open a new Terminal window and check the version, the extensions and the settings file:

php -v php -m php --ini

The version starts with PHP 8.5. The list of extensions must include curl and openssl. The --ini check must show Loaded Configuration File: C:\php\php.ini.

winget also has these builds: winget install --id PHP.PHP.NTS.8.5 -e It adds the php command for you, but it doesn’t create php.ini: the --ini check shows the folder where to put it.

Run a site with the built-in web server

PHP has a small web server for development. Go to the project folder and start it. Replace C:\projects\site with your folder. Then open http://localhost:8000 in a browser. Stop the server with Ctrl-C.

cd C:\projects\site php -S localhost:8000

The server handles one request at a time and is meant only for your own PC. For a real site use a web server like Nginx or IIS with PHP over FastCGI. Laravel starts the same server with:

php artisan serve

Install Composer

Composer installs PHP libraries for a project. On Windows it has its own installer: download Composer-Setup.exe from https://getcomposer.org/download/ and run it. It asks which PHP to use: if it doesn’t find it on its own, point it to C:\php\php.exe. Then it adds the composer command to PATH. If it reports a problem with openssl, check that extension in php.ini. Then open a new Terminal window:

composer -V

If PHP doesn’t start: common errors

  • 'php' is not recognized as an internal or external command, operable program or batch file.: open a new Terminal window. If it still fails, check that PATH has C:\php and that php.exe lies directly in that folder, not in a subfolder.
  • The code execution cannot proceed because VCRUNTIME140.dll was not found.: install the Visual C++ Redistributable x64 as described above.
  • 'vcruntime140.dll' 14.0 is not compatible with this PHP build: the Visual C++ Redistributable is too old for this PHP. Install the latest one from the same link.
  • PHP Warning: PHP Startup: Unable to load dynamic library 'curl': PHP can’t find its extensions. Check extension_dir = "C:\php\ext" in php.ini and that you took the x64 zip for 64-bit Windows.
  • could not find driver when connecting to a database: the PDO extension for it is off. Turn on extension=pdo_mysql (or pdo_pgsql, pdo_sqlite) and restart the server.
  • Loaded Configuration File: (none) in the --ini check: PHP doesn’t see your php.ini. It must lie next to php.exe and be called exactly php.ini, not php.ini.txt.

If you also work on a Mac

MacWashing, System Junk: Xcode junk, user caches, installers and logs found, 22.83 GB ready to be cleaned

System Junk in MacWashing finds the caches of every app it knows, including those hidden inside app data, plus logs, Xcode junk and leftovers of deleted apps. It shows how much each takes and clears them in one go. Anything debatable stays unchecked until you decide.

Free trial · macOS 14 or later

Questions and answers

How do I install PHP on Windows?

Download the x64 Non Thread Safe zip from php.net, unpack it to C:\php, copy php.ini-development to php.ini, turn on the extensions you need and add C:\php to PATH. Then check the version in a new Terminal window: php -v

NTS or TS: which do I need?

NTS for the command line, Composer, the built-in server, IIS and Nginx. TS only if you load PHP into Apache as a module.

How do I update PHP?

Download the new zip, keep a copy of your php.ini, unpack the new files over C:\php and put your php.ini back. When moving to a new version, such as 8.4 to 8.5, compare it with the new php.ini-development, since settings change between versions.