How To Setup Apache on Windows Server

Updated on 09 May, 2025
Learn how to set up Apache on Windows Server with XAMPP or manual installation, including optional PHP integration.
How To Setup Apache on Windows Server header image

Apache HTTP Server is a widely used open-source web server that allows users to host websites, serve static and dynamic content, and run applications using PHP or other server-side languages. It’s known for its flexibility, performance, and broad support across platforms.

This article explains how to set up Apache on Windows Server. It covers two approaches: using a bundled package like XAMPP for a fast start, and manually installing Apache for a more customizable environment. The article also covers optional PHP integration to serve dynamic content.

Prerequisites

Before you begin, ensure you have:

  • A Windows Server instance (any modern version like 2016, 2019, or 2022).
  • Administrator privileges to install software and modify firewall settings.

Set Up Apache Using XAMPP

If your goal is to get a fully functional web server running quickly, consider using XAMPP. XAMPP bundles Apache, PHP, MySQL, and a control panel for easy management.

Why Use XAMPP for Apache on Windows?

  • One-click installer for all components.
  • GUI control panel to start/stop services.
  • Great for local development or testing.

Even with XAMPP, you can freely modify Apache’s configuration files or extend the environment for advanced needs.

Install Apache HTTP Server Manually

For more control and a leaner setup, follow the steps below to manually install Apache on Windows Server.

Download and Extract Apache HTTP Server

  1. Go to the Apache HTTP Server download page.
  2. Select a binary distribution for Windows, such as one from Apache Lounge.
  3. Download the MSI Installer or ZIP file.
  4. During setup:
    • Choose “All Users”.
    • Select “Service Mode” to run Apache as a Windows service.
    • Keep port 80 as default unless another service is using it.

Install and Register Apache as a Windows Service

  • Complete the installation using the MSI wizard or extract the ZIP manually.
  • Use the Apache Monitor to manage the service.
  • Or open services.msc, find Apache2.4, and start it from there.

Verify Apache Installation in the Browser

Open your browser and visit http://127.0.0.1. Apache serves the default welcome page when the server runs successfully.

Serve Static and Dynamic Content with Apache

Apache serves files from the htdocs directory, located inside the Apache installation folder (e.g., C:\Apache24\htdocs).

  • Replace or add your .html, .php, or other files here.
  • To use other directories or domains, configure Virtual Hosts in httpd.conf.

Understand Apache Configuration Files

This section describes Apache's key configuration files and how they influence server behavior.

Apache’s behavior is controlled by these key configuration files:

File Purpose
httpd.conf Main server configuration file. Controls ports, modules, and behavior.
.htaccess Optional overrides applied per-directory. Often used in htdocs.

For production use, it's best to modify the httpd.conf directly instead of relying heavily on .htaccess.

Add PHP Support to Apache

To serve dynamic web pages with PHP:

Download a Thread-Safe PHP Build for Windows

  1. Visit the official PHP for Windows downloads.
  2. Download a Thread Safe ZIP package matching your Apache version.
  3. Extract the ZIP to a directory such as C:\php.

Configure Apache to Load the PHP Module

Edit your Apache httpd.conf file and add these lines at the bottom:

ini
LoadModule php_module "C:/php/php8apache2_4.dll"
AddType application/x-httpd-php .php
PHPIniDir "C:/php"

Replace php8apache2_4.dll with the actual file from your PHP directory that matches your installed PHP version. Check using /php directory to confirm.

Test PHP Integration on Windows

  1. Restart Apache from the Apache Monitor or services.msc.

  2. Create a test file at C:\Apache24\htdocs\test.php with the following content:

    php
    <?php phpinfo(); ?>
    
  3. Open your browser and navigate to http://127.0.0.1/test.php.

If PHP is configured correctly, Apache serves the PHP configuration info page.

Conclusion

In this article, you set up the Apache HTTP Server on Windows Server using two possible approaches: a quick-start installation with XAMPP, and a manual installation for more granular control. You learned how to verify the Apache service, serve static web files, and optionally configure PHP support to enable dynamic content.

With Apache installed and running, your Windows Server is now ready to host local or production websites. To further harden and optimize your setup, consider enabling HTTPS, setting up virtual hosts, and following security best practices for public-facing deployments.

Comments

No comments yet.