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
Step 1: Download PHP
- Visit the PHP official website
- 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:\phpStep 3: Configure environment variables
-
- On ‘This PC’ perform a Right-click and select Properties.
- Click on Advanced system settings -> Environment Variables.
- Find the ‘Path’ variable ( Under system variables ) and click Edit.
- Finally, add your PHP directory path just like C:\php and click OK.
- On ‘This PC’ perform a Right-click and select Properties.
Step 4: Test Installation
Ok, Open cmd/PowerShell and type:php -v
Install PHP Using XAMPP
Step 1: Installing XAMPP Server
-
-
- Visit the XAMPP download page.
- Download it for Windows.
- Run and follow the installation wizard. (You must select Apache and PHP)
-
Step 2: Starting Apache Server
-
-
- Open the XAMPP Control Panel.
- Click Start next to Apache to launch the server.
-
Step 3: Test PHP Installation
-
-
- Create a new file named
test.php
in thehtdocs
folder (e.g.,C:\xampp\htdocs\test.php
). - Add the following code to the file:
<?php phpinfo(); ?>
- Open your browser and navigate to
https://localhost/test.php
. - If PHP is working, you’ll see a page displaying PHP configuration details.
- Create a new file named
-
Install PHP Using Chocolatey
Step 1: Install Chocolatey
-
-
- Open Command Prompt as Administrator.
- 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
-
-
- Run the following command to install PHP:
choco install php
- Run the following command to install PHP:
-
Install PHP on Windows Subsystem for Linux (WSL)
Step 1: Install WSL
-
-
- Open Command Prompt as Administrator.
- Run the following command to install WSL:
wsl --install
-
Step 2: Install PHP
-
-
- Open your WSL terminal.
- Run the following commands to install PHP:
sudo apt update sudo apt install php
-
Install PHP Using Docker
Step 1: Install Docker
-
-
- Download Docker Desktop from the official website.
- Install Docker Desktop and start it.
-
Step 2: Run PHP in a Docker Container
-
-
- Open Command Prompt or Terminal.
- Run the following command to start a PHP container:
docker run -it --rm php:latest
-
Install PHP Using Laragon
Step 1: Download and Install Laragon
-
-
- Visit the official Laragon website.
- Download the installer for Windows and run it.
-
Step 2: Start Laragon
-
-
- Open Laragon and start the server.
- 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