How to Use Apache Webserver to Host a Website? (original) (raw)

Last Updated : 3 Jun, 2026

Apache Webserver is an open-source software developed by the Apache Software Foundation that handles HTTP/HTTPS requests between browsers and servers. It processes user requests and delivers web content like pages, images, and data. Its modular design makes it flexible and widely used for hosting websites.

It performs the following tasks:

Steps to use Apache Webserver to host a website

Step 1: Configure Apache

**1. Open the Apache Configuration File

**2. Set the ServerName and DocumentRoot

ServerName localhost:80

DocumentRoot "C:/Apache24/htdocs/mywebsite"
<Directory "C:/Apache24/htdocs/mywebsite">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted

**3. Restart Apache

httpd -k restart

httd -k start

Step 2: Configuring Virtual Hosts (Optional)

If you plan to host multiple websites, configure virtual hosts for easier and more efficient management.

**1. Open httpd-vhosts.conf at C:\Apache24\conf\extra\httpd-vhosts.conf and add your virtual host configuration:

<VirtualHost *:80>
ServerAdmin webmaster@mywebsite.com
DocumentRoot "C:/Apache24/htdocs/mywebsite"
ServerName mywebsite.com
ErrorLog "logs/mywebsite.com-error.log"
CustomLog "logs/mywebsite.com-access.log" common

<Directory "C:/Apache24/htdocs/mywebsite">  
    Options Indexes FollowSymLinks  
    AllowOverride All  
    Require all granted  
</Directory>  

**2. Save the file and restart Apache

httpd.exe -k restart

Step 3: Deploy Your Website Files

1. Create a directory for your website inside the Apache htdocs directory, either manually or using the following command:

mkdir C:\Apache24\htdocs\mywebsite

2. Copy your website files (HTML, CSS, JavaScript, etc.) into the mywebsite directory.

Step 4: Testing Website