Apache on Windows
In this page:
Why Windows Is Different
There's no official Apache binary from apache.org for Windows in the same simple sense as a Linux package -- Apache doesn't officially distribute prebuilt Windows binaries at all. Instead, most people either use a third-party build (Apache Lounge is a well-known one) or, far more commonly, install a bundled stack like XAMPP or WAMP, which packages Apache, MySQL, and PHP together with an easy installer.
Installing via XAMPP
XAMPP is the most common way to run Apache on Windows for local development: download the installer from apachefriends.org, run it, and it installs Apache, MySQL/MariaDB, PHP, and phpMyAdmin together under a folder like C:\xampp\. The XAMPP Control Panel lets you start and stop Apache with a button, which replaces the systemctl commands used on Linux.
Running Apache as a Windows Service
A standalone Apache install for Windows (rather than XAMPP) is typically registered as a Windows service so it starts automatically. From an elevated command prompt inside Apache's bin folder:
``
httpd.exe -k install
httpd.exe -k start
httpd.exe -k stop
httpd.exe -k restart
``
Once installed as a service, it also appears in the Windows Services app (services.msc), where you can start, stop, and set it to launch on boot the same way as any other Windows service.
Config File Locations on Windows
On a XAMPP install, the main config file is at C:\xampp\apache\conf\httpd.conf, with virtual hosts typically in C:\xampp\apache\conf\extra\httpd-vhosts.conf. A standalone Apache Lounge-style install keeps the same conf\httpd.conf layout under wherever you extracted it. The configuration *syntax* is identical to Linux -- only the file paths (using backslashes, and typically a C:\ drive) differ.
- Apache directives on Windows still use forward slashes in paths inside the config file itself (e.g.
DocumentRoot "C:/xampp/htdocs"), even though Windows normally uses backslashes.
Common Windows Port Conflicts
Port 80 is frequently already in use on Windows by Internet Information Services (IIS), Skype, or the "World Wide Web Publishing Service." If Apache fails to start with an error about the port being in use, either stop the conflicting service or change Apache's Listen directive to a different port, like 8080, for local development.
Example: Managing Apache as a Windows service
REM Run from an elevated Command Prompt inside Apache's bin\ folder
httpd.exe -k install
httpd.exe -k start
httpd.exe -k stop
httpd.exe -k restart
{# Flagged by hand after confirming a runner can't handle this example
(a shell command / go.mod file stored as a TopicExample, a language
feature the configured runner version doesn't support, or output
that blows a runner's sandbox limit) -- see TopicExample.norun.
Never render the run button for these, regardless of language,
since it would just fail at execute_code (or worse, hang the
Judge0 queue on a submission that can never finish cleanly). #}
- Expecting an official apache.org Windows installer the way there's an official Linux package -- most people get Apache on Windows through XAMPP/WAMP or a third-party build like Apache Lounge.
- Not noticing IIS or Skype already has port 80 open, then assuming a broken Apache config when the real error is "port already in use."
- Using Windows-style backslash paths (
C:\xampp\htdocs) insidehttpd.confdirectives, when Apache's config syntax expects forward slashes even on Windows.
- Apache is the web server software that sits between the internet and your website's files, handling requests, routing, and responses; it's installed and run differently across operating systems but configured with the same directive syntax everywhere.
- On Ubuntu/Debian, Apache is the
apache2package managed withsystemctlanda2ensite/a2enmod; on RHEL-family Linux it'shttpd; on Windows it's most commonly installed via XAMPP or run as a Windows service withhttpd.exe -k.
Chapter Quiz — Complete all 4 topics to unlock
0/4 topics done
Complete these topics first: