How To Install Apache Web Server On Ubuntu 20.04
How To Install Apache Web Server On Ubuntu 20.04
How To Install Apache Web Server On Ubuntu 20.04
04
Menu
Menu
This guide will take you through the installation of the Apache webserver on Ubuntu
20.04. It includes managing the Apache2 services, open webserver port in the rewall,
testing the Apache2 installation, and con guring a Virtual Host environment.
Requirements:
https://www.tecmint.com/install-apache-web-server-on-ubuntu-20-04/ 1/22
12/04/2021 How to Install Apache Web Server on Ubuntu 20.04
1. First, log into your Ubuntu 20.04 system and update your system packages using the
following apt command.
2. Once the update process is complete, install the Apache2 web server software as
follows.
3. While installing the Apache2 package, the installer triggers systemd to automatically
start and enable the apache2 service. You can verify that the apache2 service is
active/running and is enabled to automatically start at system startup using the following
systemctl commands.
https://www.tecmint.com/install-apache-web-server-on-ubuntu-20-04/ 2/22
12/04/2021 How to Install Apache Web Server on Ubuntu 20.04
4. Now that your apache web server is running, it’s time to learn some basic management
commands to manage the apache process using the following systemctl commands.
https://www.tecmint.com/install-apache-web-server-on-ubuntu-20-04/ 3/22
12/04/2021 How to Install Apache Web Server on Ubuntu 20.04
$ ls /etc/apache2/*
6. The following are the key con guration les and sub-directories you should take note
of:
Note that if the server’s FQDN is not set globally, you will get the following warning every
time you check the apache2 service status or run a con guration test.
Set the 'ServerName' directive globally in the main apache con guration le to
suppress this message.
https://www.tecmint.com/install-apache-web-server-on-ubuntu-20-04/ 4/22
12/04/2021 How to Install Apache Web Server on Ubuntu 20.04
Add the following line in the le (replacing webserver1.tecmint.com with your FQDN).
ServerName webserver1.tecmint.com
8. After adding the server name in the apache con guration, check the con guration
syntax for correctness, and restart the service.
https://www.tecmint.com/install-apache-web-server-on-ubuntu-20-04/ 5/22
12/04/2021 How to Install Apache Web Server on Ubuntu 20.04
9. Now when you check the apache2 service status, the warning should not appear.
Testing Apache on Ubuntu 20.04
https://www.tecmint.com/install-apache-web-server-on-ubuntu-20-04/ 6/22
12/04/2021 How to Install Apache Web Server on Ubuntu 20.04
11. To test if the Apache2 webserver installation is working ne, open a web browser, and
use your server’s IP address to navigate:
http://SERVER_IP
To nd out your server’s public IP address, use any of the following curl commands.
$ curl ifconfig.co
OR
$ curl ifconfig.me
OR
$ curl icanhazip.com
If you see the Apache Ubuntu default welcome web page, it means your web server
installation is working ne.
https://www.tecmint.com/install-apache-web-server-on-ubuntu-20-04/ 7/22
12/04/2021 How to Install Apache Web Server on Ubuntu 20.04
Therefore Virtual Host is a term that refers to the practice of running more than one web
site/application (such as example.com and example1.com) on a single server.
Additionally, Virtual Hosts can be “name-based “(meaning that you have multiple
domain/hostnames running on a single IP address), or “IP-based” (meaning that you have
a different IP address for every web site).
Note that the default virtual host which serves the Apache Ubuntu default welcome web
page which is used to test the Apache2 installation is located in the /var/www/html
directory.
$ ls /var/www/html/
https://www.tecmint.com/install-apache-web-server-on-ubuntu-20-04/ 8/22
12/04/2021 How to Install Apache Web Server on Ubuntu 20.04
12. For this guide, we will create a virtual host for the web site called
linuxdesktop.info . So let’s rst create the web document root for the site which will
store the site’s web les.
13. Next, set the appropriate ownership and permissions on the created directory.
<html>
<head>
<title>Welcome to linuxdesktop.info!</title>
</head>
<body>
<h1>Congrats! The new linuxdesktop.info virtual host is working fine.<
</body>
</html>
15. Next, you need to create a virtual host con guration le (which should end with the
.conf extension) for the new site under the /etc/apache2/sites-available directory.
$ sudo vim /etc/apache2/sites-available/linuxdesktop.info.conf
https://www.tecmint.com/install-apache-web-server-on-ubuntu-20-04/ 9/22
12/04/2021 How to Install Apache Web Server on Ubuntu 20.04
Then copy and paste the following con guration it the le (remember to replace
www.linuxdesktop.info with your FQDN).
<VirtualHost *:80>
ServerName www.linuxdesktop.info
ServerAlias linuxdesktop.info
DocumentRoot /var/www/html/linuxdesktop.info
ErrorLog /var/log/apache2/linuxdesktop.info_error.log
CustomLog /var/log/apache2/linuxdesktop.info_access.log combined
</VirtualHost>
16. Next, enable the new site and reload the Apache2 con guration to apply the new
changes as follows.
17. Finally, test if the new virtual host con guration is working ne. In a web browser, use
your FQDN to navigate.
http://domain-name
If you can see the index page for your new website, it means the virtual host is working
ne.
Check Virtual Host in Apache
https://www.tecmint.com/install-apache-web-server-on-ubuntu-20-04/ 10/22
12/04/2021 How to Install Apache Web Server on Ubuntu 20.04
That’s all! In this guide, we have shown how to install the Apache webserver on Ubuntu
20.04. We also covered how to manage the Apache2 services, open the HTTP and HTTPS
services/ports in the UFW rewall, tested the Apache2 installation, and con gured and
tested a Virtual Host environment. Do you have any queries, use the comment form below
to reach us.
How To Install Linux Mint 20 “Ulyana” How to Install Nginx Web Server on
Ubuntu 20.04
If you liked this article, then do subscribe to email alerts for Linux tutorials. If you have
any questions or doubts? do ask for help in the comments section.
TecMint is the fastest growing and most trusted community site for
any kind of Linux Articles, Guides and Books on the web. Millions of
people visit TecMint! to search or browse the thousands of published
articles available FREELY to all.
If you like what you are reading, please consider buying us a coffee (
or 2 ) as a token of appreciation.
https://www.tecmint.com/install-apache-web-server-on-ubuntu-20-04/ 11/22
12/04/2021 How to Install Apache Web Server on Ubuntu 20.04
Related Posts
https://www.tecmint.com/install-apache-web-server-on-ubuntu-20-04/ 12/22
12/04/2021 How to Install Apache Web Server on Ubuntu 20.04
https://www.tecmint.com/install-apache-web-server-on-ubuntu-20-04/ 13/22
12/04/2021 How to Install Apache Web Server on Ubuntu 20.04
https://www.tecmint.com/install-apache-web-server-on-ubuntu-20-04/ 14/22
12/04/2021 How to Install Apache Web Server on Ubuntu 20.04
Protect Apache Against Brute Force or DDoS Attacks Using Mod_Security and
Mod_evasive Modules
https://www.tecmint.com/install-apache-web-server-on-ubuntu-20-04/ 15/22
12/04/2021 How to Install Apache Web Server on Ubuntu 20.04
aktarus
November 10, 2020 at 6:19 pm
https://www.tecmint.com/install-apache-web-server-on-ubuntu-20-04/ 16/22
12/04/2021 How to Install Apache Web Server on Ubuntu 20.04
Reply
Name *
Email *
Website
Save my name, email, and website in this browser for the next time I comment.
Notify me of followup comments via e-mail. You can also subscribe without
commenting.
Post Comment
This site uses Akismet to reduce spam. Learn how your comment data is processed.
https://www.tecmint.com/install-apache-web-server-on-ubuntu-20-04/ 17/22
12/04/2021 How to Install Apache Web Server on Ubuntu 20.04
https://www.tecmint.com/install-apache-web-server-on-ubuntu-20-04/ 18/22
12/04/2021 How to Install Apache Web Server on Ubuntu 20.04
Linux Foundation LFCS and LFCE Certi cation Study Guide [eBooks]
https://www.tecmint.com/install-apache-web-server-on-ubuntu-20-04/ 19/22
12/04/2021 How to Install Apache Web Server on Ubuntu 20.04
Difference Between su and sudo and How to Con gure sudo in Linux
https://www.tecmint.com/install-apache-web-server-on-ubuntu-20-04/ 20/22
12/04/2021 How to Install Apache Web Server on Ubuntu 20.04
bmon – A Powerful Network Bandwidth Monitoring and Debugging Tool for Linux
How to Use ‘fsck’ to Repair File System Errors in Linux
https://www.tecmint.com/install-apache-web-server-on-ubuntu-20-04/ 21/22
12/04/2021 How to Install Apache Web Server on Ubuntu 20.04
CloudStats.me – Monitors Your Linux Servers and Websites from the Cloud
9 Best Twitter Clients for Linux That You Will Love to Use
Tecmint: Linux Howtos, Tutorials & Guides © 2021. All Rights Reserved.
The material in this site cannot be republished either online or of ine, without our permission.
https://www.tecmint.com/install-apache-web-server-on-ubuntu-20-04/ 22/22