How To Setup Apache on Windows Server

Updated on November 21, 2023
How To Setup Apache on Windows Server header image

This tutorial will show you how to run the Apache HTTP server on Windows Server.

Running an HTTP server will allow you to host a web site and put up files for download. Apache is open-source software and one of the top HTTP servers available.

Bundled packages

If you just want to get a Web server running quickly, you can install one of the ready-made packages such as XAMPP which include Apache, PHP, MySQL, and an easy to control interface. Even when using such a package, there are no constraints when it comes to modifying the server configuration. However, for an advanced setup, you may want to manually install your web server.

Installing Apache

Download the Windows MSI installer from the Apache download page and fill in the details. Choose "All Users" and "Service" mode. You will most likely want to leave the port at 80, but you can change it. You simply need to make sure that this port is opened in the Windows Firewall.

After running the installer, the Apache Monitor will have been installed. You can control the status of Apache services from this application - using start, stop, and restart. You can also do so from Windows' services.msc. By now, you should be able to contact your server on http://127.0.0.1 and see the default Apache page.

You can add, edit, and remove web files from your web server by changing the htdocs folder within the Apache folder. This is the default location for web files. Alternatively, you could make use of virtual hosts in order to use other directories, or set up sub-domains.

Apache has two important configuration files: .htaccess, which applies on a directory-by-directory basis within the web files, and httpd.conf inside Apache's conf folder, which addresses the main configuration.

Installing PHP

PHP allows you to make use of PHP scripts on your web server and display the results to users.

Download the Windows version of PHP from PHP Windows downloads. Download the proper version and then extract the zip file to c:\php.

Next, edit Apache's httpd.conf to include the following:

LoadModule php5_module "c:/php/php5apache2_2.dll"
AddType application/x-httpd-php .php
PHPIniDir "C:/php"

You should then restart the Apache server. In order to test PHP, create a test.php file in your htdocs folder with the following content:

<?php phpinfo() ?>

... then check the output at http://127.0.0.1/test.php.


Your Windows/Apache setup is complete.