How to Install Apache, MariaDB and PHP on Windows (Manual Setup)

This guide explains how to manually install and configure Apache, MariaDB, and PHP on Windows Server 2022.
This approach is modular and lets you update each component independently without reinstalling everything (unlike XAMPP).

Install Apache HTTP Server

1.1 Download Apache

  1. Go to https://www.apachelounge.com/download/
  2. Download the latest Win64 build (VC++ x64), e.g. httpd-2.4.xx-win64-VS17.zip.

images

  1. Download the Redistributable Go to the official Microsoft download page:

images

Download Visual C++ Redistributable: https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist?view=msvc-170

images

1.2 Extract and Install

images

  1. Extract to C:\Apache24 (avoid spaces in the path).

    images

  2. Open Command Prompt (Admin) and run:
cd C:\Apache24\bin
httpd.exe -k install -n "Apache24"
httpd.exe -t

Output:

Syntax OK

1.3 Start Apache

net start Apache24

Visit http://localhost/ — you should see "It works!".

images

1.4 Open Firewall

netsh advfirewall firewall add rule name="Allow Apache HTTP" dir=in action=allow protocol=TCP localport=80

If Apache fails to start or shows errors, check and adjust the following in C:\Apache24\conf\httpd.conf:

  • ServerName Directive:
    Find #ServerName www.example.com:80
    Change it to:

    ServerName localhost:80
  • Listen Directive:
    Make sure Apache is listening on the right port:

    Listen 80

    If port 80 is used by another service (like IIS), change it to Listen 8080.

  • DocumentRoot and Directory:
    Ensure they point to the correct folder:

    DocumentRoot "C:/Apache24/htdocs"
    <Directory "C:/Apache24/htdocs">
  • Use Forward Slashes:
    All paths in httpd.conf must use / (forward slashes), not \.

    images

Install MariaDB

2.1 Download and Install

  1. Go to https://mariadb.org/download/
  2. Select Windows (64-bit) installer (MSI).

    images

  3. Run installer:

    images

    images

    images

  • Choose a root password

    images

  • Install as a Windows Service (recommended)
  • Enable “Start the MariaDB service after installation”

    images

    images

2.2 Verify MariaDB

Open Command Prompt and run:

mysql -u root -p

If you get this error:

'mysql' is not recognized as an internal or external command,
operable program or batch file.

It means Windows cannot find mysql.exe because the MariaDB bin folder is not in your PATH.

Fix: Add MariaDB to System PATH

  1. Locate the MariaDB bin folder.
    Commonly:
    C:\Program Files\MariaDB XX.X\bin
    (or for MySQL: C:\Program Files\MySQL\MySQL Server X.X\bin)

    images

  2. Edit Environment Variables:

    • Search for Environment Variables in Start Menu.
    • Click Edit the system environment variables.
    • Click Environment Variables…
    • Under System variables, select Path → Edit.

    images

  • Click New and paste the full path to the bin folder.

    images

  • Click OK on all windows.
  1. Restart Command Prompt
    Open a new Command Prompt (old ones won’t pick up the new PATH).

  2. Test again:
mysql -u root -p

Now the command should work and ask for your password.

Enter your root password and verify the MariaDB prompt appears.

images

Install PHP

3.1 Download PHP

  1. Go to https://windows.php.net/download/
  2. Download the Thread Safe x64 ZIP (e.g. php-8.x.x-Win32-vs16-x64.zip).

    images

3.2 Extract PHP

  1. Extract to C:\php
  2. Copy php.ini-development to php.ini

    images

  3. Edit php.ini:
    • Enable required extensions by removing ; (e.g. extension=mysqli)

Configure Apache to Use PHP

  1. Open C:\Apache24\conf\httpd.conf in a text editor.
  2. Add these lines at the end:
# PHP Configuration
LoadModule php_module "C:/php-8.4.12-Win32-vs17-x64/php8apache2_4.dll"
AddHandler application/x-httpd-php .php
PHPIniDir "C:/php-8.4.12-Win32-vs17-x64"
  1. Restart Apache:
net stop Apache24
net start Apache24

Test PHP

Create a test file:

cd C:\Apache24\htdocs
echo "<?php phpinfo(); ?>" > info.php

Open http://localhost/info.php — you should see the PHP Info page.

images

✅ You now have a fully working LAMP stack on Windows Server 2022 (manual setup).
Apache, MariaDB, and PHP are independent, making it easy to upgrade each component in the future.


CrownCloud - Get a SSD powered KVM VPS at $4.5/month!
Use the code WELCOME for 10% off!

1 GB RAM / 25 GB SSD / 1 CPU Core / 1 TB Bandwidth per month

Available Locations: LAX | MIA | ATL | FRA | AMS