Blog by Debabratta Jena
Apache server setup in Windows 10

Apache server setup in Windows 10

Last modified on Oct 30, 2020

In this article I will show you to install apache 2.4 http server in windows 10 pro and after successful installation, we will configure the server according to our basic need to host a simple website.

Installing Apache http server is really very easy and the following process will work for any version of windows.


Before, we start server set up, we should know.

Why apache?



A web server is a kind of software which handles all http request on the web. There are several web software available on the market like Apache, Nginx, MS IIS etc. But, among these Apache http server is the most popular web server used by more than 35 percent of the website on the web. The Apache HTTP Server is a project of The Apache Software Foundation. Most Linux servers use apache http server, however it can also be run at Microsoft server.
Here is the step by step guide to setup apache http server :
  1. Download the Apache server zip file from ApacheHaus.
  2. Extract the files and save it in C drive.
  3. Go to folder where your httpd file exists. In my case it is C:\Apache24\bin. Copy the address and paste this into your path of environment variable in Advanced system settings.


If you have completed these steps, you have done it.

Now you can check whether it is successfully installed or not. For this open command prompt and type httpd. This command will start your server.

When you start your server for the first time, firewall will block the process, but you need to allow access in order to let apache server run on your machine.
Firewall blocks apache.
To check, server is running or not, open your browser and type "localhost" in the address bar. You should see something like this,
apache-server-setup-homepage
If you see the above page in your browser, that means your apache http server installation is complete. Next you need to configure server to host your website.

In the htdocs directory you would see a default page index.html, this is the page you see when you type localhost in your browser. You can replace this index.html file with yours.


What is htdocs?


The htdocs directory in within apache root directory is actually home to all hosted websites. It is the directory which server looks for files when any external request comes. So, we must keep all individual websites which we want to host, in this directory. Keeping websites in any other directory won't be accessible ubless, you set up your server accordingly.

Suppose, we make a project with name MyWeb, and save it in htdocs directory. Now, when you type localhost/MyWeb in the browser, you should see the contents of of your default home page of your MyWeb project. If you create another website with name MyWeb2 and save it within htdocs, you can access it by typing localhost/MyWeb2 in the browser.

The default port of apache http server is 80, so whether you type localhost:80 or localhost, both are same. Basically, you need not change this port number for apache server but in case you want to change default port number on which server listens. Go to conf directory, you will find a httpd.conf file, open this file in notepad. You will see a line like this Listen 80, replace 80 with any number you want, save the file and close. Now restart the server and type localhost:80, you will see the server no more listens at this port 80.

What is httpd.conf file?


This is the main configuaration file of apache http server. All server configuarations are stored in this file. By editing this file you can change your apache server configuarations. It contains the # configuration directives that give the server its instructions. See Apache website for detailed information.

Edit the httpd.conf file cautiously, if you do anything wrong, the server wont startup. So before you edit the file, keep a copy of the file so that you can replace with the copy.

httpd.conf vs .htaccess file


http.conf is the main configuration file which is applied on the server and all the directories under it. But, if we do not have access to http.conf file, we can configure .htaccess file. The .htaccess file is the per directory configuration file or it is also called distributed configuration file. That means, configuration in this file is only applied to that directory in which it resides and all sub-directories under it. It is only used when the server hosts more than one website. Admin creates one .htaccess file for each of the home directory of the hosted website on the server. It is generally found at the public_html directory of the web server. The .htaccess file overrides the httpd.conf.

One more major diffrence between is, httpd.conf file is read on every server startup but .htaccess is read on every client request.