Windows Server 2022 is made up of various wide-ranging roles and functions that allow its customers to run workloads securely, enable new hybrid cloud scenarios, and modernize their applications with evolving business landscapes. However, many more useful functionalities can be added to the server by installing Apache Web Server. It unlocks the opportunity of setting up an open-source HTTP server so that users can host and manage their applications.
In this article, we’ll list out the steps you need to take to install Apache Web Server on Windows Server 2022.
Explore Our Top Picks for Windows VPS Hosting
Provider | User Rating | Recommended For | |
---|---|---|---|
4.9 | Security | Visit Ultahost | |
4.8 | Performance | Visit Kamatera | |
4.0 | Affordability | Visit IONOS |
Step 1: Download Apache Files for Windows
The first step to install Apache Web Server on Windows Server 2022 is to download the Apache packages for Windows. They are freely available on ApacheLounge.
Apache is available in both 32-bit (x86) and 64-bit (x64) versions, depending upon the version of Windows that your Windows Server is running. We will be moving forward in this guide with the assumption that the Windows server is running a 64-bit operating system.
Therefore, we need to download Apache 2.4.52 Win64 (httpd-2.4.52-win64-VC15.zip).
In addition, ApacheLounge also mentions that you need to have the relevant C++ Redistributable for Visual Studio installed on your server too. So, make sure you install the latest 14.30.30704 Visual C++ Redistributable for Visual Studio 2015-2022.
It is most likely that will already have it installed on your system. If not, download and run “vc_redist_x64.exe†(for a 64-bit operating system), or “vc_redist_86.exe†(for a 32-bit system) from the ApacheLounge website.
Step 2: Unzip the Apache Files
Once the zip file is downloaded, extract its contents to a suitable location on your Windows server to be configured. It is recommended to extract the contents in the C drive of the server.
Step 3: Configure Apache
The next step to install Apache Web Server on Windows 2022 is configuring Apache to the location where you have extracted its files.
Go to the “conf†subdirectory and locate the “httpd.conf†file. The configuration file assumes that you’ve extracted Apache to C:Apache24 by default. However, if you have extracted Apache to a different location (i.e. D:Apache), you need to change it accordingly in the configuration file as well. For that, you need to update the ${SRVROOT} variable in the “httpd.conf†file to refer to the location which you have selected.
Hence, Change Define SRVROOT “C:/Apache24†to Define SRVROOT “D:/Apacheâ€
If you can’t find the SRVROOT variable in your “httpd.conf†file, then the location might have been referenced individually at every instance. In that case, you need to manually update all instances of “C:/Apache24“. Therefore:
Change ServerRoot “C:/Apache24†to ServerRoot “D:/Apacheâ€
Change DocumentRoot “C:/Apache24/htdocs†to DocumentRoot “D:/Apache/htdocsâ€
Change <Directory “C:/Apache24/htdocsâ€> to <Directory “D:/Apache/htdocsâ€>
Change ScriptAlias /cgi-bin/ “C:/Apache24/cgi-bin/†to ScriptAlias /cgi-bin/ “D:/Apache/cgi-bin/â€
In addition, you also need to make some other modifications regardless of where you have extracted the Apache files. These are:
Add “ExecCGI†to the “Options†directive:
Find the line “Options Indexes FollowSymLinks†and add “ExecCGI†to it:
Options Indexes FollowSymLinks ExecCGI
Allow the Execution of .cgi/.pl Files
This essentially allows the usage of CGI/Perl scripts outside of the cgi-bin directory.
Find the following line in the configuration file and uncomment it by removing the # signal.
AddHandler cgi-script .cgi
Additionally, add the following line below it:
AddHandler cgi-script .pl
Both of these lines tell Apache to execute the .cgi/.pl files rather than presenting them as text to a web browser.
Determine the Location of Perl Directly from the Windows Registry
Write the following line to the end of the configuration file:
ScriptInterpreterSource Registry
The first line of .cgi/.pl files directs Apache to the install location of Perl. Adding this line allows Apache to ignore the first line and determine the location of Perl directly from the Windows Registry.
Step 4: Run Apache
Open a Command Prompt or PowerShell in the “bin†folder at the location where you extracted Apache. Right-click while holding “Shift†and select “Open command window here†or “Open PowerShell window here“.
For command prompt, enter the following command to start Apache:
httpd.exe
For PowerShell, enter the following command to start Apache:
& "D:Apachebinhttpd.exe"
(In the place of D:Apache, write the location where you had extracted Apache in step 2)
You might see a Windows Firewall prompt. Allow the access to be appropriate. Failing to allow Apache access through your server’s firewall will result in other computers/devices being unable to connect to your web server.
You will come across a “could not bind to address†error if another service is already running on Apache’s default port (80). Therefore, check that you don’t currently have an IIS (Internet Information Services) server already running. If so, you either need to stop/disable IIS in order to run Apache or change the port on either IIS or Apache to allow both services to run simultaneously. Refer to the vendor’s documentation for information about changing server listening ports.
Step 5: Test Whether Apache is Running Successfully
Keep the previous command window open, and navigate to http://127.0.0.1 with your web browser. If Apache is running on your Windows Server 2022 you will see the message “It works!†in your browser.
Step 6: Install Apache as a Windows Service default
After the previous step, Apache will exit after you close the command/PowerShell window. To ensure that your Apache web server runs all the time, you need to install it as a Windows service. Here is how you can install Apache as a Windows Service in an easy and quick way:
Step 1: Open an administrative command prompt window and enter the following command:
httpd.exe -k install -n "Apache HTTP Server"
You will see the following output,
Installing the 'Apache HTTP Server' service The 'Apache HTTP Server' service is successfully installed. Testing httpd.conf.... Errors reported here must be corrected before the service can be started.
Step 2: Then, write the following command and press ‘Enter‘ In the Command Prompt window.
services.msc
Look for the service “Apache HTTP Server.†You should see “Automatic†towards the left of that line. If you don’t, change the Startup Type to “Automatic†by double-clicking the line.
Step 3: Finally, restart your server and open a web browser once you are logged back in. Navigate to the following address in the web browser: http://127.0.0.1
Step 7: Configure Windows’ Firewall – Open to World
Configuring the Windows’ Firewall is the final step to install Apache web server on Windows Server 2022. It allows connections from the Internet to your new web server. Here are the steps that you need to follow:
Step 1: Go to Start Menu and enter a search query, “firewallâ€. Select the “Windows Firewall With Advanced Security†item.
Step 2: Select the “New Rule†on the right-hand sidebar.
Step 3: Click on “Port,†and then click Next. Then, select the radio button next to “Specific remote ports:†and enter the following into the input box: 80, 443, 8080.
Step 4: Click Next and select the “Allow the connection†option.
Step 5: Click ‘Next’. Make sure that all the boxes on the next page are selected and then click ‘Next‘ again.
Step 6: In the “name†section, enter a description which ensures that you will be able to remember the rule’s purpose later such as: “Allow Incoming Apache Traffic.â€
Step 7: Click “Finishâ€.
Step 8: Test the server for other devices by connecting to your server’s IP address from a device other than the one you are using to connect to the server right now. Open a web browser on that device and enter the IP address of your server like http://142.250.183.238
You will be able to see the test web page that shows the message “It works!â€.
If the test page works successfully and shows the message, it means that you have successfully configured Windows Firewall and other devices can connect to your web server. These were the simple steps in which you can install Apache Web Server on Windows Server 2022.
- Your search to the best windows hosting can end by clicking here.