How to Install PHP on Windows 10: Complete Step-by-Step Guide

Learn how to securely install and configure PHP on Windows 10. This step-by-step guide covers downloading PHP, setting environment variables, editing the php.ini file, and running your first PHP script.

How to Install PHP on Windows 10: Complete Step-by-Step Guide
Photo by Ben Griffiths / Unsplash

Running PHP locally on Windows 10 is an excellent way to build and test web applications in a familiar desktop environment. PHP is a powerful scripting language used by popular frameworks like Laravel and Symfony.

In this tutorial, you'll learn how to install PHP on Windows 10, configure it correctly, and verify that everything works—without relying on third-party stacks like XAMPP or WAMP.

Downloading PHP for Windows

The first step is to download the correct PHP version from the official PHP for Windows downloads page.

As of now, PHP 7.4 and PHP 8.0 are the most commonly used versions. PHP 8 offers newer features and improved performance, while PHP 7.4 is still widely supported.

💡
Explore the PHP 8.0 release notes to see what's new before choosing your version.

After selecting the release, you'll notice several build types.

Choosing the Right Build: x86, x64, TS, and NTS

You’ll need to understand which version to choose:

  • x86: For 32-bit systems
  • x64: For 64-bit systems (recommended for most users)
  • TS (Thread Safe): Recommended for Apache or if running PHP with multithreaded servers
  • NTS (Non Thread Safe): Typically used with IIS or when PHP is run in a single-threaded environment
💡
To check the architecture of your processor, open the Windows Start Menu and search for “System.” Under the "System Type" section, you'll find whether your system is 32-bit or 64-bit.

Most developers should download the x64 Thread Safe version. Download the .zip file, which should be around 24 MB.

Verifying the Download with SHA256

After downloading, confirm the file’s integrity using a checksum:

certutil -hashfile C:\path\to\php.zip SHA256

Compare the result with the hash listed on the PHP download page. If they match, the file is safe. If not, re-download it from the official site.

Extracting and Setting Up PHP

Once verified, extract the .zip archive to a preferred location (e.g., C:\php).

Adding PHP to the Windows PATH

To make PHP accessible from anywhere in the command prompt:

  1. Search for “Environment Variables” in the Windows Start Menu.
  2. Click on “Environment Variables…” in the System Properties window.
  3. Under “User variables”, select Path and click Edit.
  4. Click New and paste the path to the folder containing php.exe (e.g., C:\php).
  5. Click OK on all windows to apply the changes.

You can now run PHP from any terminal window.

Configuring PHP

To fully enable PHP’s capabilities, you'll need to set up a configuration file.

Creating a php.ini File

In your PHP folder, you’ll find two template files: php.ini-development and php.ini-production. For development purposes:

  1. Rename php.ini-development to php.ini.
  2. Open php.ini in a text editor.

Editing php.ini Settings

Make the following changes to enable important features:

  • Uncomment the line:
extension_dir = "ext"
  • Enable essential extensions by uncommenting these lines:
extension=curl
extension=intl
extension=mbstring
extension=openssl
extension=pdo_mysql

These extensions are crucial for running modern PHP frameworks and handling database connections securely.

Verifying Your PHP Installation

To check if PHP is correctly installed and configured, run:

php -v

You should see output similar to:

PHP 8.0.7 (cli) (built: Jun  2 2021 00:41:03) ( ZTS Visual C++ 2019 x64 )

To run a simple test command:

php -r "echo 'Hello World!';"

If everything is set up correctly, you’ll see Hello World! printed in the terminal.

What's Next: Setting Up a Development Environment

With PHP installed, consider setting up a full web development environment. You can:

Composer will be especially useful if you plan to work with frameworks like Laravel or Symfony, enabling robust project structures and powerful package management.

Conclusion

Installing and configuring PHP on Windows 10 is straightforward when you follow the correct steps. By selecting the right version, verifying the download, setting the environment path, and configuring essential extensions, you can begin developing PHP applications directly from your Windows machine.

Once you're up and running, tools like WSL and Composer can take your development workflow to the next level.