This text explains the way to install PHP 8.2 and Apache 2.4 on Windows 10 or 11 (64-bit).

Linux and macOS users often have Apache and PHP pre-installed or available via package managers. Windows requires somewhat more effort. The steps below may match with other editions of Windows, PHP, and Apache, but check the documentation of every dependency for specific instructions.


  1. Why PHP?
  2. Why Install PHP Locally?
  3. Alternative Installation Options
  4. Installing Apache (optional)
  5. Installing PHP

Why PHP?

PHP stays essentially the most widespread and popular server-side programming language on the Web. It’s installed by most web hosts, and has a straightforward learning curve, close ties with the MySQL database, superb documentation, and a large collection of libraries to chop your development time. PHP will not be perfect, but you must consider it in your next web application. It’s the language of selection for Facebook, Slack, Wikipedia, MailChimp, Etsy, and WordPress (the content management system which powers almost 45% of the online).

Why Install PHP Locally?

Installing PHP in your development PC lets you create and test web sites and applications without affecting the info or systems in your live server.

Alternative Installation Options

Before you jump in, there could also be a less complicated installation options…

Using an all-in-one package

All-in-one packages can be found for Windows. They contain Apache, PHP, MySQL, and other useful dependencies in a single installation file. These packages include XAMPP, WampServer and Web.Developer.

These packages are easy to make use of, but they could not match your live server environment. Installing Apache and PHP manually will enable you learn more in regards to the system and configuration options.

Using a Linux virtual machine

Microsoft Hyper-V (provided in Windows Skilled) and VirtualBox are free hypervisors which emulate a PC so you may install one other operating system.

You possibly can install any version of Linux, then follow its Apache and PHP installation instructions. Alternatively, distros equivalent to Ubuntu Server provide them as standard (although they will not be the newest editions).

Using Windows Subsystem for Linux 2

WSL2 can be a virtual machine, but it surely’s tightly integrated into Windows so activities equivalent to file sharing and localhost resolution are seamless. You possibly can install quite a lot of Linux distros, so check with the suitable Apache and PHP instructions.

Using Docker

Docker creates a wrapper (referred to as a container) around pre-configured application dependencies equivalent to Apache, PHP, MySQL, MongoDB, and most other web software. Containers appear like full Linux Virtual Machines but are considerably more lightweight.

When you’ve installed Docker Desktop on Windows, it’s easy to download, configure, and run Apache and PHP.

Docker is currently considered one of the best option for organising a PHP development environment. Try SitePoint’s article Setting Up a Modern PHP Development Environment with Docker for an entire guide to setting it up.

Installing Apache (optional)

The next sections describe the way to install Apache and PHP directly on Windows.

PHP provides a built-in web server, which you may launch by navigating to a folder and running the PHP executable with an -S parameter to set the localhost port. For instance:

cd myproject
php -S localhost:8000

You possibly can then view PHP pages in a browser at http://localhost:8000.

This will be adequate for quick tests, but your live server will use Apache or similar web server software. Emulating that environment as closely as possible permits more advanced customization and will prevent development errors.

To put in Apache, download the newest Win64 ZIP file from and extract its Apache24 folder to the basis of your C: drive. You’ll also have to install the Visual C++ Redistributable for Visual Studio 2015–2020 (vc_redist_x64); the page has a link at the highest.

Open a cmd command prompt (not PowerShell) and begin Apache with:

cd C:Apache24bin

You might need to just accept a firewall exception before the server starts to run. Open http://localhost in a browser and an “It really works!” message should appear. Note:

  • C:Apache24confhttpd.conf is Apache’s configuration file if it is advisable to change server settings.

  • C:Apache24htdocs is the online server’s root content folder. It incorporates a single index.html file with the “It really works!” message.

If Apache fails to begin, one other application may very well be hogging port 80. (Skype is the prime candidate, and the Windows app won’t allow you to disable it!) If this happens, edit C:Apache24confhttpd.conf and alter the road Listen 80 to Listen 8080 or some other free port. Restart Apache and, from that time onward, you may load web files at http://localhost:8080.

Stop the server by pressing Ctrl + C within the cmd terminal. The ReadMe file within the ZIP also provides instructions for installing Apache as a Windows service so it auto-starts on boot.

Installing PHP

Install PHP by following the steps below. Note that there’s multiple method to configure Apache and PHP, but that is possibly the quickest method.

Step 1: Download the PHP files

Get the newest PHP x64 Thread Secure ZIP package from

Create a recent php folder in the basis of your C: drive and extract the content of the ZIP into it.

You possibly can install PHP anywhere in your system, but you’ll need to vary the paths referenced below should you use anything apart from C:php.

Step 3: Configure php.ini

PHP’s configuration file is php.ini. This doesn’t exist initially, so copy C:phpphp.ini-development to C:phpphp.ini. This default configuration provides a development setup which reports all PHP errors and warnings.

You possibly can edit php.ini in a text editor, and you could need to vary lines equivalent to those suggested below (use search to seek out the setting). Generally, you’ll have to remove a number one semicolon (;) to uncomment a worth.

First, enable any required extensions in accordance with the libraries you ought to use. The next extensions needs to be suitable for many applications including WordPress:


If you ought to send emails using PHP’s mail() function, enter the small print of an SMTP server within the [mail function] section (your ISP’s settings needs to be suitable):

[mail function]
; For Win32 only.
smtp_port = 25

; For Win32 only.
sendmail_from =

Step 4: Add C:php to the PATH environment variable

To make sure Windows can find the PHP executable, you should add it to the PATH environment variable. Click the Windows Start button and kind “environment”, then click Edit the system environment variables. Select the Advanced tab, and click on the Environment Variables button.

Scroll down the System variables list and click on Path, followed by the Edit button. Click Recent and add C:php.

Note that older editions of Windows provide a single text box with paths separated by semi-colons (;).

Now OK your way out. You shouldn’t have to reboot, but you could have to close and restart any cmd terminals you will have open.

Step 5: Configure PHP as an Apache module

Ensure Apache is not running and open its C:Apache24confhttpd.conf configuration file in a text editor. Add the next lines to the underside of the file to set PHP as an Apache module (change the file locations if crucial but use forward slashes quite than Windows backslashes):

# PHP8 module
PHPIniDir “C:/php”
LoadModule php_module “C:/php/php8apache2_4.dll”
AddType application/x-httpd-php .php

Optionally, change the DirectoryIndex setting to make use of index.php because the default instead of index.html. The initial setting is:

DirectoryIndex index.html

Change it to:

DirectoryIndex index.php index.html

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

cd C:Apache24bin
httpd -t

Syntax OK will appear … unless you will have errors in your configuration.

If all went well, start Apache with httpd.

Step 6: Test a PHP file

Create a recent file named index.php in Apache’s web page root folder at C:Apache24htdocs. Add the next PHP code:


Open an online browser and enter your server address: http://localhost/. A PHP version page should appear, showing all PHP and Apache configuration settings.

You possibly can now create PHP sites and applications in any subfolder of C:Apache24htdocs. If it is advisable to work multiple project, consider defining Apache Virtual Hosts so you may run separate codebases on different localhost subdomains or ports.

Further information:

Better of luck!