Articles

How to Install PHP on Windows 10/11: A Complete Guide

install php on windows

Whether you’re building apps, learning to code, or setting up WordPress locally on your Windows machine, installing PHP is your first step.

In this guide, I’ll show you 3 easy methods to install PHP on Windows 10/11:

  • Manual install for full control.
  • XAMPP Server for beginners (one-click setup!).
  • Pro tools like Docker, WSL, Laragon, or Chocolatey.

By the end, you’ll be running PHP scripts, testing sites, or even launching your own tools. Ready? Let’s do it!

Table of Contents

Why Install PHP on Windows?

Before diving into the installation process, let’s quickly discuss why you might need PHP on your Windows machine:
  • Local Development: Test and debug PHP scripts without needing a live server. (You can visit our PHP Unit testing article).
  • Learning PHP: Practice coding and build projects locally.
  • Web Applications: Run popular PHP-based applications like WordPress, Joomla, or Laravel.

Manually PHP Setup on Windows

Install PHP on Windows Installing PHP manually gives you full control over the configuration and version of PHP you want to use. Follow these steps:

Step 1: Download PHP

  1. Visit the PHP official website
  2. Choose the latest stable version, e.g., PHP 8.x (Thread Safe is recommended for use with web servers like Apache, while Non-Thread Safe is better for CLI usage.) and download the ZIP package for Windows 32/64 bit.

Step 2: Extract the zip file

Extract the downloaded ZIP file to a specific directory, For example, C:\php

Step 3: Configure environment variables

    1. On ‘This PC’ perform a Right-click and select Properties.This PC
    2. Click on Advanced system settings -> Environment Variables. Advanced system settings Environment Variables
    3. Find the ‘Path’ variable ( Under system variables ) and click Edit. Environment Variables Path
    4. Finally, add your PHP directory path just like C:\php and click OK. Adding php path to env

Step 4: Test Installation

Ok, Open cmd/PowerShell and type:
php -v
php version cmd If PHP is installed correctly, the version number will be displayed.

Install PHP Using XAMPP

Installing PHP on Windows using XAMPP XAMPP is an open-source web server(including PHP, MySQL, and Apache) to develop and test websites on a local server.

Step 1: Installing XAMPP Server

      1. Visit the XAMPP download page.
      2. Download it for Windows.
      3. Run and follow the installation wizard. (You must select Apache and PHP)

Step 2: Starting Apache Server

xammp server
      1. Open the XAMPP Control Panel.
      2. Click Start next to Apache to launch the server.

Step 3: Test PHP Installation

      1. Create a new file named test.php in the htdocs folder (e.g., C:\xampp\htdocs\test.php).
      2. Add the following code to the file:
        <?php
        phpinfo();
        ?>
      3. Open your browser and navigate to https://localhost/test.php.
      4. If PHP is working, you’ll see a page displaying PHP configuration details.

Install PHP Using Chocolatey

chocolatey php Chocolatey is a package manager for Windows that makes it easy to install software. Here’s how to install PHP using Chocolatey:

Step 1: Install Chocolatey

      1. Open Command Prompt as Administrator.
      2. Run the following command to install Chocolatey:
        @"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"

Step 2: Install PHP

      1. Run the following command to install PHP:
        choco install php

Install PHP on Windows Subsystem for Linux (WSL)

wsl php If you prefer using Linux on Windows, you can install PHP on WSL. Here’s how:

Step 1: Install WSL

      1. Open Command Prompt as Administrator.
      2. Run the following command to install WSL:
        wsl --install

Step 2: Install PHP

      1. Open your WSL terminal.
      2. Run the following commands to install PHP:
        sudo apt update
        sudo apt install php

Install PHP Using Docker

docker php windows Docker is a popular platform for running applications in containers. Here’s how to install PHP using Docker:

Step 1: Install Docker

      1. Download Docker Desktop from the official website.
      2. Install Docker Desktop and start it.

Step 2: Run PHP in a Docker Container

      1. Open Command Prompt or Terminal.
      2. Run the following command to start a PHP container:
        docker run -it --rm php:latest

Install PHP Using Laragon

laragon php Laragon is a portable, fast, and powerful universal development environment for PHP. Here’s how to install PHP using Laragon:

Step 1: Download and Install Laragon

      1. Visit the official Laragon website.
      2. Download the installer for Windows and run it.

Step 2: Start Laragon

      1. Open Laragon and start the server.
      2. Laragon comes with pre-installed PHP, so you can start using PHP immediately.

Manual Installation vs. XAMPP: Which is Better?

Feature Manual Installation XAMPP
Ease of Use Requires technical knowledge Beginner-friendly
Customization Full control over settings Limited customization
Additional Tools Only PHP Includes Apache, MySQL, etc.
Best For Advanced users Beginners and quick setups

Conclusion

Installing PHP on Windows 10 or 11 is a straightforward process, whether you choose to do it manually or use tools like XAMPP, Chocolatey, WSL, Docker, or Laragon. If you’re new to PHP or web development, XAMPP or Laragon are the easiest ways to get started. On the other hand, if you need more control over your environment, manual installation or Docker might be good. By following this guide, you should now have PHP successfully installed on your Windows machine.

FAQ

Yes! You can use tools like XAMPP and Laragon, or manually configure different PHP versions and switch between them using environment variables.

For beginners, XAMPP is the easiest option since it bundles PHP, Apache, and MySQL in a single package.

Open Command Prompt and type:

php -v

This usually happens when PHP’s path isn’t added to Environment Variables. Make sure  your PHP installation path (Like C:\PHP) is included in your system’s Path variable.

  • Thread Safe (TS): Used for web servers like Apache.
  • Non-Thread Safe (NTS): Used for command-line scripts (CLI) where threading isn’t needed.

Not always. But if you modify Environment Variables, restarting Command Prompt or your PC ensures the changes take effect.

Yes, the process is identical for both operating systems.

Yes! You can run scripts directly using:

php script.php
PHP unit testing: Learn How to Test Code With PHPUnit
How to Install PHP on macOS: Intel Chip and Apple Silicon(M1/M2/M3)
Leave a Reply

Your email address will not be published. Required fields are marked *

Shopping cart
Sign in

No account yet?

Create an Account