0% found this document useful (0 votes)
2 views

09. Apache Web Server

This document provides a step-by-step guide to setting up an Apache HTTP web server on an Ubuntu machine, specifically for the domain dfn50303.com. It includes requirements, installation instructions, and configuration steps for creating a virtual host to serve web pages. By following the instructions, users will have a functioning web server that can host multiple sites.

Uploaded by

aimanyusuf7
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

09. Apache Web Server

This document provides a step-by-step guide to setting up an Apache HTTP web server on an Ubuntu machine, specifically for the domain dfn50303.com. It includes requirements, installation instructions, and configuration steps for creating a virtual host to serve web pages. By following the instructions, users will have a functioning web server that can host multiple sites.

Uploaded by

aimanyusuf7
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

SETUP APACHE HTTP WEB SERVER

By Ruzaini Roni © 2023. Politeknik Mukah

Introduction

A Web server is a program that uses HTTP (Hypertext Transfer Protocol) to serve the files that
form Web pages to users, in response to their requests, which are forwarded by their
computers' HTTP clients. Dedicated computers and appliances may be referred to as Web
servers as well. Apache is the most widely-installed Web server and a major component in
LAMP stack.

Requirements
1. A machine as Web server
2. A client machine with GUI operating systems (Windows 10 or Ubuntu
Desktop)
3. DNS server is turned on
4. Privileged access to your Ubuntu system as root or via sudo command is
required
Outcomes
You will provide basic web service using apache2 on the www.dfn50303.com machine. By
the end of this activity, you will have a web server on Ubuntu Server 22.04.1 LTS. You
also manage the Apache service via systemd and create virtual hosts for setting up websites.

By Ruzaini Roni © 2023. Politeknik Mukah


Instructions

1. On the www machine, update system and install the Apache package (and all required
dependencies):

sudo apt update


sudo apt install -y apache2

2. After the installation finished, check with the systemd init system to make sure the
service is running by typing:

sudo service apache2 status

or,

sudo systemctl status apache2

Note: Apache on Ubuntu 22.04.1 LTS has one server block enabled by default that is
configured to serve documents from the /var/www/html directory.

When you required a server hosting multiple sites, create a directory structure within
/var/www for our dfn50303.com site, leaving /var/www/html in place as the default
directory to be served if a client request does not match any other sites.

3. Create the directory for dfn50303.com as follows, using the -p flag to create any
necessary parent directories::

sudo mkdir -p /var/www/dfn50303.com/html

4. Next, create an index.html page using nano or your favorite editor::

sudo nano /var/www/dfn50303.com/html/index.html

5. Then, edit the html file as followings:

<html>
<head>
<title>Welcome to DFN50303.com!</title>
</head>
<body>

By Ruzaini Roni © 2023. Politeknik Mukah


<h1>Success! The DFN50303.com server block is working!</h1>
</body>
</html>

6. Save and close the file when you are finished.

7. In order for Apache to serve this content, it's necessary to create a virtual host file
with the correct directives. Instead of modifying the default configuration file located
at /etc/apache2/sites-available/000-default.conf directly, let's make a new
one at /etc/apache2/sites-available/dfn50303.com.conf:

sudo nano /etc/apache2/sites-available/dfn50303.com.conf

8. Modify the file as the following configuration block:

<VirtualHost *:80>
ServerAdmin [email protected]
ServerName dfn50303.com
ServerAlias www.dfn50303.com
DocumentRoot /var/www/dfn50303.com/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Note: Notice that you are updated the DocumentRoot to a new directory and ServerAdmin
to an email that the dfn50303.com site administrator can access. You are also added two
directives: ServerName, which establishes the base domain that should match for this
virtual host definition, and ServerAlias, which defines further names that should match
as if they were the base name.

9. Save and close the file when you are finished.

10. Enable the dfn50303.com.conf file with the a2ensite


tool:

sudo a2ensite dfn50303.com.conf

11. Disable the default site defined in 000-default.conf:

sudo a2dissite 000-default.conf

By Ruzaini Roni © 2023. Politeknik Mukah


12. Next, test for configuration errors:

sudo apache2ctl configtest

You should see the following output:

Output
Syntax OK

13. Restart Apache to implement your changes:

sudo systemctl restart apache2

14. Apache should now be serving your domain name. From any machine on your
network, you can test this by navigating to http://www.dfn50303.com
(or http://dfn50303.com).

By Ruzaini Roni © 2023. Politeknik Mukah

You might also like