How To Install PHP On Windows OS — 6 Steps To Follow

How To Install PHP On Windows OS
How To Install PHP On Windows OS

1. Introduction

Setting up a server may be intimidating, even more so when installing languages such as PHP. Have no idea where to begin installing PHP on your server? There are several methods to accomplish this depending on your specific configuration. Where do you obtain PHP, which version, what are the prerequisites for its operation, and how do you install PHP on the Windows operating system?

We’ll address all of them in our comprehensive PHP installation guide.

Lets get started!

Table of Content:

1. Introduction

2. What is PHP

3. PHP Prerequisites

4. How to Install PHP on a Windows Operating System

5. Summary

2. What is PHP?

PHP is an open-source scripting language that is mostly used for web development and backend (server-side) programming.

In simple terms, PHP can be installed on a server to enable the execution of scripts (e.g. pieces of code to add forms to your site).

It is server-side rather than client-side, which means that it operates on the backend rather than the browser.

It interacts nicely with HTML, which makes it an excellent choice for web development.

Additionally, it is one of the most accessible web programming languages, making it a popular choice for startups. However, it is highly strong and well-suited to complex website features.

Numerous websites and programmers make use of PHP and its numerous extensions (.NET, Apache, and MySQL may sound familiar). WordPress is largely written in PHP, and the majority of its plugins and themes are likewise written in PHP.

2.1 Does Your Server Need PHP?

Now that you understand what PHP is, why would you want to install it on your server?

The primary reason is that it is required to get WordPress up and operating, as it is virtually entirely written in PHP. PHP is also the language that drives the majority of WordPress functions, hooks, themes, and plugins.

Therefore, if you want to experiment with running a WordPress test server or setting up a staging site, you’ll need to install PHP.

Apart from that, PHP is an excellent starting point for inexperienced developers. It is simple to use in comparison to other online scripting languages, but this does not mean that capability is sacrificed. If you’re competent enough, you can accomplish almost anything with it.

PHP, on the other hand, is highly popular. As a result, there are several extensions and resources available online.

Apart from that, you’ll need to study PHP if you want to learn how to code WordPress themes and plugins. Creating a test server is an excellent approach to conducting experiments.

Take notice that many web hosting servers provide PHP and WordPress pre-installed. The only time you’ll need to accomplish this manually is if you’re starting from scratch with a server, either on your own computer or in an unmanaged hosting environment.

3. PHP Prerequisites

Prior to installing PHP, you’ll want to ensure that your server is capable of handling it. Fortunately, the needs are modest, and much of the required software is almost certainly already installed on your computer.

If this is your first time setting up a server, you should read this instruction on setting up a local server on several operating systems. While the specifics differ per operating system, you should be familiar with the command line and prepared to install new applications.

Whichever operating system you choose to install PHP on, it will require a webserver to run. Additionally, you’ll almost certainly need to install a database such as MySQL, so keep that in mind.

The following table summarises the PHP requirements for each operating system, beginning with Linux:

  • An ANSI C compiler.
  • Module-specific components like GD graphics libraries or PDF libraries.
  • Optional: Autoconf 2.59+ (for PHP versions < 7.0), Autoconf 2.64+ (for PHP versions > 7.2), Automake 1.4+, Libtool 1.4+, re2c 0.13.4+, and Bison.
  • Additionally, you should be comfortable with Unix-like operating systems.

Now, the PHP requirements for Windows are as follows:

  • Multiple Windows operating systems are supported by PHP 5.5+, although users of PHP 7.2.0+ are not permitted to use Windows 2008 or Windows Vista.
  • Visual C Runtime (CRT).

Depending on your PHP version, you may need Visual Studio 2012, 2015, 2017, or Microsoft Visual C++ Redistributable for Visual Studio 2019.

Finally, there are no requirements for macOS, as PHP is included with the operating system. We’ll walk you through the process of enabling it below.

3.1 Where to Download PHP files

If you need to manually download the PHP files, they may be found on the official site’s PHP downloads page.

Avoid installing anything from third-party websites unless you are certain they are secure, as downloading files from third-party websites might result in the installation of malware accidentally.

If you’re downloading for a Windows PC, search for the “Windows downloads” link in each PHP version and double-check that you’re installing the appropriate files.

You may also install older versions of PHP, but this is not suggested unless you are confident in your abilities, as they expose your server to bugs and significant security vulnerabilities.

If you’re using a Linux distribution, you shouldn’t need to download the files via a website and should instead utilize the command line. That will be discussed in further detail below.

3.2 Which PHP Version Should I Use?

If you clicked the download link above, you’re probably overwhelmed by the sheer volume of files. Which PHP version is correct?

In general, if you’re beginning a brand-new project without regard for compatibility, you should install the newest stable version of PHP.

Although it is occasionally possible to get beta versions of PHP that are even newer, they are frequently problematic and are only published to assist developers in gathering feedback. Generally, you should stick to stable releases.

What about previous iterations? Each PHP version introduces new functionality but also introduces new incompatibilities with existing features. If you require a feature that is not supported by the most recent PHP version, you may use an earlier version; nevertheless, you should adhere to the currently supported versions.

If in doubt, use the most recent version of PHP.

Bear in mind that WordPress is only compatible with specific PHP versions. Although it theoretically supports PHP versions beginning with 5.6.20, they are rather ancient and are thus not recommended. WordPress versions 7.2 to 7.4 are presently the most well-supported.

PHP version 8 is also compatible, although this is a fairly new version, and not all plugins operate correctly at the moment. If you’re concerned about compatibility, stay with PHP 7.4. You may read our PHP benchmarks page to determine the performance of various PHP CMSes and frameworks on various PHP versions.

4. How to Install PHP on a Windows Operating System

Unlike macOS and Linux, you do not need to install PHP through the command line on a Windows PC (though it is an option if you consider).

Allowing IIS and then using WebPI to install PHP is a simple approach to install PHP from here. After starting WebPI, look under the Products tab for it. On the desired version, click Add, and then click Install.

Additionally, you may download PHP for Windows and configure it manually to operate with IIS. If you’re using IIS, be sure to obtain a non-thread-safe version.

If this all seems too hard, you may instead install WampServer or XAMPP, which include everything you need to get started with a web server: Apache, a database, and, of course, PHP.

These instructions are compatible with the majority of recent Windows operating systems, including Windows 10, 7, and Vista. If you’re running an earlier version of Windows, you should see the documentation for legacy Windows installations.

Windows may require some additional settings in order for PHP to function correctly, so be sure to consult the recommended Windows configuration guidelines. You only need to make a few minor changes.

PHP may be installed using the procedures below. There are various methods for configuring Apache and PHP, but this is likely the quickest.

Step 1: Download the PHP files

You’ll need the PHP installation for Windows. PHP is available in a variety of flavours. Ascertain that you are using the most recent PHP 8 x64 Thread Safe ZIP package available at

Step 2: Extract the files

Create a new PHP folder in the C: drive’s root directory and extract the ZIP file’s contents into it.

PHP can be installed anywhere on your system, however, the locations specified below will need to be changed if C:\php isn’t used.

Step 3: Configure php.ini

The configuration file for PHP is called php.ini.

This file does not exist by default; thus, transfer C:\php\php.ini-development to C:\php\php.ini.

This default setting creates a development environment in which all PHP faults and warnings are reported.

Several lines may require modification with a text editor (use search to find the current value). In most circumstances, uncommenting a setting requires removing the leading semicolon (;).

To begin, enable any necessary extensions. This will vary depending on the libraries being used, but the following additions should suffice for the majority of applications:




extension=pdo mysql

If you wish to send emails through PHP’s mail() function, insert the following information in the [mail function] section:

[mail function]

; For Win32 only.




smtp_port = 25

; For Win32 only.


sendmail_from =

Step 4: Add C:\php to the path environment variable

To guarantee that Windows can locate the PHP executable, you must modify the environment variable PATH. To edit the system environment variables, click the Windows Start button, enter “environment,” and then click Edit the system environment variables. The Advanced tab is selected, and the Environment Variables button is clicked.

Select Path followed by the Edit button at the bottom of the System variables list. Select New and add C:\php:

Add C:\php to the path environment variable
Add C:\php to the path environment variable

Notably, earlier versions of Windows use a single text field with each route denoted by a semi-colon (;).

Continue clicking OK until you are prompted to exit. Although you should not need to reboot, you may need to close and restart any open cmd terminals.

Step 5: Configure PHP as an Apache module

Ascertain that Apache is not operating and access its configuration file C:\Apache24\conf\httpd.conf in a text editor. Add the following lines to the bottom of the file to configure PHP as an Apache module (you may need to adjust the file locations accordingly):

# PHP8 module

PHPIniDir “C:/php”

LoadModule php_module “C:/php/php8apache2_4.dll”

AddType application/x-httpd-php .php

Alternately, modify the DirectoryIndex option to load index.php rather than index.html when it is available. The basic configuration is as follows:

<IfModule dir_module>

DirectoryIndex index.html


Replace it with:

<IfModule dir_module>

DirectoryIndex index.php index.html


Save httpd.conf and test the updates from a cmd command line:

cd C:\Apache24\bin

httpd -t

Syntax acceptable should appear… Unless your configuration has problems.

Restart Apache using httpd if everything went fine.

Step 6: Test a PHP file

Create a new file named index.php in Apache’s web page root folder at C:\Apache24\htdocs and add the following PHP code:




Open a web browser and type http://localhost/ into the address bar. A page titled “PHP version” will display the different PHP and Apache setup parameters.

PHP sites and apps may now be created in any sub-folder of C:\Apache24\htdocs. If you need to work on various projects concurrently, consider configuring Apache Virtual Hosts to enable you to execute distinct codebases on different localhost domains or ports.

5. Summary

Regardless of the operating system you’re using, installing PHP isn’t difficult. It is required if you wish to create a WordPress test server. Aspiring PHP programmers will benefit much by setting up a web server and installing PHP on it.

Ascertain that you download PHP via the command line or from its official website. You can either download the most recent stable version of PHP or a version that is compatible with WordPress.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Lauren Gibbs

Lauren Gibbs

Lauren Gibbs is a web developer specialized in Laravel Development. She loves to write about technology blogs. You can find her bylines in many famous blogs.