How to Install Apache on Ubuntu 20.04

In this article, we want to teach you How to Install Apache on Ubuntu 20.04.

Apache HTTP server is the most widely used web server software. Developed and maintained by Apache Software Foundation, Apache is open-source software available for free.

Requirements

Before we start to teach you how to install Apache you need to log in to your server with a non-root user with root privileges. you can check our article about the Initial server setup with Ubuntu 20.04 to learn how to log in as a non-root user.

How to Install Apache on Ubuntu 20.04

After you finish the Initial server setup with Ubuntu 20.04 you can easily install Apache on your server.

Install Apache on Ubuntu 20.04

Apache is available in Ubuntu’s default software repository. you just need to update the local package index then install the apache.

Run the following command to update the packages:

sudo apt update

Then, install the apache2 package :

sudo apt install apache2

After you install Apache on Ubuntu 20.04 you need to adjust the firewall.

Adjust the firewall on Ubuntu 20.04

Apache registers itself with UFW to provide a few application profiles that can be used to enable or disable access to Apache through the firewall.

You list available applications with the following command:

sudo ufw app list

Your output should be like this:

Output:
Available applications:
Apache
Apache full
Apache secure
OpenSSH

Allow Apache with the following command:

sudo ufw allow 'Apache'

You can see the active status and a List of allowed HTTP traffic with the following command:

sudo ufw status
Output
Status: active
To Action From
-- ------ ----
Apache ALLOW Anywhere
Apache (v6) ALLOW Anywhere (v6)

At this point,  you install Apache on Ubuntu 20.04 and now you can check your web server.

Check your Apache Webserver

You can check that the Apache service is running with the following command:

sudo systemctl status apache2
Output
● apache2.service - The Apache HTTP Server
Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor prese>
Active: active (running) since Wed 2021-08-25 08:21:32 CEST; 7min ago
Docs: https://httpd.apache.org/docs/2.4/
Main PID: 1926 (apache2)
Tasks: 55 (limit: 2282)
Memory: 6.6M
CGroup: /system.slice/apache2.service
├─1926 /usr/sbin/apache2 -k start
├─1928 /usr/sbin/apache2 -k start
└─1929 /usr/sbin/apache2 -k start

It’s better to request a page from Apache to test it.  for doing this you need your server’s IP address. you can get your IP with the following command:

hostname -I

Or you can use the icanhazip tool to get your IP. run the following command:

curl -4 icanhazip.com

Enter your server’s IP address in your favorite browser.

http://your_server_ip

you will see the page like the image below:

install-apache-on-ubuntu-20-04

When you see this page it means that the Apache is working correctly. Here we go to see some basic information about the Apache process.

Mange The Apache process on Ubuntu 20.04

When you are done with the install Apache, you can learn some basic management commands.

You can stop your web server with the following command:

sudo systemctl stop apache2

To start it again you can use:

sudo systemctl start apache2

Also, you can stop and then start the service with:

sudo systemctl restart apache2

If you have made some configuration changes you need to reload your service after doing that with the following command:

sudo systemctl reload apache2

To disable the service run the following command:

sudo systemctl disable apache2

Then you can re-enable it to start the service every time the server boots:

sudo systemctl enable apache2

Conclusion

By following the steps that we said in the article you can easily Install your Apache webserver. don’t forget to check the Initial server setup on the Linux Tutorials before you start your Apache installation.

Hope you enjoy it.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles

POPULAR TAGS

Most Popular