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
- Go to https://www.apachelounge.com/download/
- Download the latest Win64 build (VC++ x64), e.g.
httpd-2.4.xx-win64-VS17.zip.

- Download the Redistributable Go to the official Microsoft download page:

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

1.2 Extract and Install

-
Extract to
C:\Apache24(avoid spaces in the path).
- 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!".

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 80If 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 inhttpd.confmust use/(forward slashes), not\.
Install MariaDB
2.1 Download and Install
- Go to https://mariadb.org/download/
-
Select Windows (64-bit) installer (MSI).

-
Run installer:



-
Choose a root password

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


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
-
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)
-
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.

-
Click New and paste the full path to the
binfolder.
- Click OK on all windows.
-
Restart Command Prompt
Open a new Command Prompt (old ones won’t pick up the new PATH). - 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.

Install PHP
3.1 Download PHP
- Go to https://windows.php.net/download/
-
Download the Thread Safe x64 ZIP (e.g.
php-8.x.x-Win32-vs16-x64.zip).
3.2 Extract PHP
- Extract to
C:\php -
Copy
php.ini-developmenttophp.ini
- Edit
php.ini:- Enable required extensions by removing
;(e.g.extension=mysqli)
- Enable required extensions by removing
Configure Apache to Use PHP
- Open
C:\Apache24\conf\httpd.confin a text editor. - 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"
- 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.

✅ 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