Hello friends, In this tutorial I’m guiding you how to host a simple website in Apache Web Server in Linux. So, let’s get started.

Install Apache

First, let’s install Apache from the apt repository in Linux. Enter the following command on your terminal to install the Apache web server:

sudo apt install apache2

After successful installation, here are some commands that may come handy while running Apache web server.

  1. To start Apache 2, run:
    $ sudo service apache2 start

  2. To restart Apache 2, run:
    $ sudo service apache2 restart

  3. To stop Apache 2, run:
    $ sudo service apache2 stop

  4. To gracefully reload Apache 2, run:
    $ sudo service apache2 reload

After starting the Apache Web Server, you may go into any browser and type http://127.0.0.1/ on Address Bar. The resulting web page looks like:

Apache2 Start

The web page rendered is the default web page provided by the Apache itself. Now, we’ll learn to replace by our website.

Create Website

For maintaining the simplicity, I’m creating a simple web project darkweb with the following file structure.

darkweb/
├── css
│   └── style.css
└── index.html

1 directory, 2 files

Inside index.html :

<!DOCTYPE  html>
<html  lang="en">
<head>
	<title>Website on Dark Web</title>
	<link  rel="stylesheet"  href="./css/style.css">
</head>
<body>
	<h1>This is my first web site on Dark Web.</h1>
</body>
</html>

And inside css/style.css:

body{
	margin: 0px;
	color: red;
	background-color: darkslateblue;
}

which results to form a webpage like :

Sample Website

Host Website on Apache Web Server

Going through the default configuration provided by the Apache, we’re going to add website we just created to the Apache web server.

Assuming our web project name is darkweb, let’s move the project to /var/www/html.

$ sudo mv darkweb/ /var/www/html

Now, we’ve hosted our website on Apache Web Server. To access the website from the Apache, first start the Apache Web Server:

$ sudo service apache2 start

And type http://127.0.0.1/darkweb/ on address bar on your browser. Now, you should see the website we just created on the browser. Here, my project name was darkweb, but the generalized URL for accessing your project is http://127.0.0.1/YOUR_PROJECT_NAME/.

After hosting on Apache, the website looks like:

result

I hope that now you’re able to host website on Apache web server.

In next tutorial of this series, I’ll be guiding you through how to install SSL certificate on Apache2 Ubuntu Server.

Thanks for reading.