Install Apache Web Server 2.4 Windows 10 ServerRoot Error
There are various reasons why a developer or DevOps professional might want to install the Apache web server locally on a Windows 10 machine. The Apache HTTP server can be used for testing purposes, to simulate a production HTTP server that acts as a cache static files for Apache Tomcat or Jetty, or it can be used simply as an internal web server for the desktop.
Fortunately, installing Apache HTTP Server on Windows is relatively simple. Although there are a few caveats you should be aware of.
The first obstacle you will encounter when trying to install Apache on Windows is the fact that you will not be able to download the installation binaries directly from apache.org. You must either clone and compile the Apache HTTP Server source code yourself or download the Apache 2.4 installation media from a third party.
Download Apache web server
A third-party download of the binaries is probably the easiest way to go. There are a number of approved options listed on Apache’s website, including:
- The Apache Lounge, which provides a simple ZIP file that you can quickly download and extract.
- Apache Haus which provides an Apache 2.4 installation file that comes with OpenSSL.
- The Apache Friends XAMPP distribution, which bundles Apache with MariaDB, PHP, and Perl.
- Bitnami, which provides a number of preconfigured virtual machines, containers, and installation media with Apache included. WAMP stack with PHP, MySQL and Apache is highly recommended.
Having been a regular Bitnami user all my life, I would say that Bitnami stacks are the best install media to use, although the the simplest approach is to simply download the Apache web server installation ZIP file from the Apache lounge.
Be warned that their website hits you with a number of spam ads, which is a bit confusing, but their download file is verifiable. Do not accidentally click on the wrong link and install adware on your computer.
Step-by-step installation of Apache on Windows
With Apache Lounge chosen as the source for Apache installation media on Windows, the steps to follow are simple:
- Download the installation media as a ZIP file
- Extract contents of Apache Web Server 2.4 zip to file system
- Locate the extracted Apache24 folder and copy this folder to the root of C:
- Open the C:Apache24bin folder and run the command httpd.exe
- View the Apache HTTP Server home page at http://localhost:80 to verify Windows installation
If the steps are followed correctly and there are no conflicts on port 80, a landing page will appear saying “It works!” if you point your browser to the localhost address. To host a website on Apache or use the server for file sharing, just add folders and files under the htdocs folder. Files placed here will immediately become available on the web.
ServerRoot must be a valid directory
A slightly surprising requirement of the Apache installation media provided by both Bitnami and Apache Lounge is that the software must be installed directly to the root of the Windows C: drive. Otherwise, you come across a “ServerRoot must be a valid directory” Error. To fix this Apache installation error, move the Apache24 folder to the C: drive or update the SRVROOT property set in line 39 of Apache’s httpd.conf file.
For those who encounter this Apache error with a Bitnami or XAMPP installation, directly run the configuration file found in the installation’s root or trash and the error will disappear.
And it’s that easy to install Apache HTTP Server on Windows 10.