How to Install Apache HTTP Server on Windows Server 2022
Apache HTTP Server is the world’s most widely deployed web server, and while Linux is its traditional home, running Apache on Windows Server 2022 is a practical choice for teams already operating in a Windows environment. This guide walks through every step from downloading the binaries to serving HTTPS traffic with virtual hosts and PHP support.
Downloading Apache for Windows (Apache Lounge)
The Apache Software Foundation does not publish official Windows binaries. The most trusted third-party source is Apache Lounge (apachelounge.com), which provides builds compiled against the latest Visual C++ runtime. Navigate to the Downloads section and grab the latest Win64 ZIP — for example, httpd-2.4.62-250207-win64-VS17.zip.
Before extracting, install the Microsoft Visual C++ Redistributable for Visual Studio 2017 or later (the exact version is listed on the Apache Lounge download page). Without it, httpd.exe will fail with a missing DLL error.
# Download the VC++ redistributable if not already installed
# Check installed runtimes first:
Get-WmiObject -Class Win32_Product | Where-Object { $_.Name -like "*Visual C++*" } | Select-Object Name, Version
Directory Layout (C:Apache24)
Extract the ZIP so that the Apache24 folder sits directly under C:. The resulting structure should look like this:
C:Apache24
bin # httpd.exe, ab.exe, apachectl equivalents
conf # httpd.conf and included configs
confextra # httpd-vhosts.conf, httpd-ssl.conf, etc.
htdocs # default document root
logs # error.log, access.log, pid file
modules # mod_rewrite.so, mod_ssl.so, etc.
cgi-bin
Apache on Windows is hard-coded to look for its configuration relative to the ServerRoot directive. If you install to a different drive or path, you must update ServerRoot in httpd.conf before starting the server, or it will refuse to start.
httpd.conf Basics
Open C:Apache24confhttpd.conf in a text editor. The minimum changes needed for a fresh install are:
# Set the server root (use forward slashes on Windows)
ServerRoot "C:/Apache24"
# Set the hostname — suppress the "could not determine server's FQDN" warning
ServerName localhost:80
# Document root for the default site
DocumentRoot "C:/Apache24/htdocs"
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
# Listen on port 80
Listen 80
Always use forward slashes in Apache configuration paths on Windows, even though Windows itself uses backslashes. Apache’s path parser does not handle backslashes consistently and you will encounter subtle startup errors if you mix them.
Installing Apache as a Windows Service
Open an elevated Command Prompt (Run as Administrator) and navigate to the Apache bin directory:
cd C:Apache24bin
# Install as a service named "Apache2.4"
httpd.exe -k install -n "Apache2.4"
# Verify the service was registered
sc query Apache2.4
# Start the service
httpd.exe -k start -n "Apache2.4"
# Or use net start / Stop
net start Apache2.4
net stop Apache2.4
After running httpd.exe -k install, you will see the service listed in Services (services.msc) with startup type “Automatic”. You can also use httpd.exe -t at any time to test the configuration file for syntax errors before restarting.
# Test configuration syntax without restarting
C:Apache24binhttpd.exe -t
# Output on success:
# Syntax OK
Configuring Virtual Hosts
Uncomment the include line in httpd.conf to enable the virtual hosts configuration file:
# In httpd.conf, uncomment:
Include conf/extra/httpd-vhosts.conf
Then edit C:Apache24confextrahttpd-vhosts.conf:
# Catch-all default virtual host
ServerName default
DocumentRoot "C:/Apache24/htdocs"
# Production virtual host
ServerName www.example.com
ServerAlias example.com
DocumentRoot "C:/inetpub/example"
ErrorLog "C:/Apache24/logs/example-error.log"
CustomLog "C:/Apache24/logs/example-access.log" combined
Options FollowSymLinks
AllowOverride All
Require all granted
Name-based virtual hosting on Windows works exactly the same as on Linux. Apache selects the virtual host by matching the Host: HTTP header against ServerName and ServerAlias directives.
Loading the PHP Module (mod_php vs FastCGI)
For PHP integration, the two common approaches are the Apache module (mod_php) and FastCGI. The mod_php approach is simpler but runs PHP in-process with Apache. FastCGI (via mod_fcgid or mod_proxy_fcgi with PHP-FPM) is more robust in production.
mod_php approach: Download PHP for Windows (Thread Safe x64) from windows.php.net, extract to C:php, and add to httpd.conf:
# Load the PHP module (adjust version as needed)
LoadModule php_module "C:/php/php8apache2_4.dll"
# Tell Apache to pass .php files to PHP
AddHandler application/x-httpd-php .php
# Set the php.ini directory
PHPIniDir "C:/php"
# Add index.php as a default document
DirectoryIndex index.php index.html
FastCGI approach with mod_proxy_fcgi: Start PHP-FPM (available in PHP 8.x for Windows), then proxy to it from Apache:
# In httpd.conf, enable required modules
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so
# In your VirtualHost block:
SetHandler "proxy:fcgi://127.0.0.1:9000"
Enabling mod_rewrite on Windows
mod_rewrite is used by nearly every PHP application including WordPress and Laravel. Ensure it is loaded in httpd.conf:
# Uncomment this line in httpd.conf
LoadModule rewrite_module modules/mod_rewrite.so
For mod_rewrite rules in .htaccess to work, the AllowOverride All directive must be set on the directory in question (as shown in the virtual host example above). A WordPress .htaccess for clean URLs looks like:
# BEGIN WordPress
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress
Configuring SSL with mod_ssl
First, uncomment the required modules and include files in httpd.conf:
LoadModule ssl_module modules/mod_ssl.so
LoadModule socache_shmcb_module modules/mod_socache_shmcb.so
# Listen on 443
Listen 443
# Include the SSL configuration
Include conf/extra/httpd-ssl.conf
Edit C:Apache24confextrahttpd-ssl.conf and update the certificate paths. For Let’s Encrypt certificates (obtained via Certbot for Windows or win-acme), the paths will be something like:
ServerName www.example.com
DocumentRoot "C:/inetpub/example"
SSLEngine on
SSLCertificateFile "C:/certs/example.com/cert.pem"
SSLCertificateKeyFile "C:/certs/example.com/privkey.pem"
SSLCertificateChainFile "C:/certs/example.com/chain.pem"
# Modern TLS configuration
SSLProtocol all -SSLv3 -TLSv1 -TLSv1.1
SSLCipherSuite ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256
SSLHonorCipherOrder off
SSLSessionTickets off
AllowOverride All
Require all granted
HTTPS Redirect
To force all HTTP traffic to HTTPS, add a redirect in the port 80 virtual host:
ServerName www.example.com
ServerAlias example.com
# Permanent redirect to HTTPS
RewriteEngine On
RewriteRule ^(.*)$ https://%{HTTP_HOST}$1 [R=301,L]
Alternatively, use the simpler Redirect directive if you do not need pattern matching:
ServerName www.example.com
Redirect permanent / https://www.example.com/
Starting, Stopping, and Testing Apache on Windows
From an elevated command prompt:
# Test configuration
C:Apache24binhttpd.exe -t
# Start, stop, restart via service name
net start Apache2.4
net stop Apache2.4
net stop Apache2.4 && net start Apache2.4
# Or via httpd.exe directly
C:Apache24binhttpd.exe -k restart -n "Apache2.4"
# Check which port Apache is listening on
netstat -ano | findstr ":80 "
netstat -ano | findstr ":443 "
# Tail the error log (PowerShell)
Get-Content C:Apache24logserror.log -Wait -Tail 50
The Windows Event Viewer (eventvwr.msc) also captures Apache service start/stop events under Windows Logs > Application, which is useful for diagnosing startup failures when the service fails before logging begins.
To verify Apache is serving correctly, open a browser and navigate to http://localhost. You should see the Apache test page from C:Apache24htdocsindex.html. For virtual host testing, add entries to C:WindowsSystem32driversetchosts pointing your test domains to 127.0.0.1.
Firewall Configuration
Windows Firewall blocks inbound connections by default. Open ports 80 and 443 so external clients can reach Apache:
# Open port 80 (HTTP)
netsh advfirewall firewall add rule name="Apache HTTP" protocol=TCP dir=in localport=80 action=allow
# Open port 443 (HTTPS)
netsh advfirewall firewall add rule name="Apache HTTPS" protocol=TCP dir=in localport=443 action=allow
# Verify
netsh advfirewall firewall show rule name="Apache HTTP"
Apache HTTP Server on Windows Server 2022 is production-capable when configured properly. The key differences from Linux are the path syntax (forward slashes in configs, backslashes in shell), service management via httpd.exe -k or net start, and the need to use Apache Lounge binaries rather than an official Apache package. With virtual hosts, mod_rewrite, PHP integration, and SSL configured as shown in this guide, you have a fully functional web server environment suitable for hosting most PHP-based web applications.