How to Install Apache on Ubuntu 22.04

Apache remains a popular choice for web server software due to its flexibility, reliability, and vast community support. With various features and functionalities, Apache allows you to configure, deploy, and maintain websites or web applications. It can also handle many tasks for you including setting up virtual hosts, managing access controls, enabling SSL/TLS encryption, and much more.

The main objective of this learning-based post is to guide the complete installation and configuration of Apache on Ubuntu 22.04.

How to Install Apache on Ubuntu 22.04?

To install the full Apache package on Ubuntu 22.04, follow the steps provided below.

Step 1: Upgrade System Packages

It is strongly recommended to keep your Ubuntu machine up to date by using the command:

sudo apt update && sudo apt upgrade -y

As you can see all the installed packages in your Ubuntu, are up to date with the latest version.

Step 2: Install Apache2 using “apt”

Install the Apache package on your Ubuntu 22.02 by executing the command:

sudo apt install apache2 -y

The above screenshot is presented with the message that Apache is installed along with its associated dependencies.

Step 3: Apache Status

To check the status of Apache service, simply run the command mentioned below from the Ubuntu terminal:

sudo systemctl status apache2

After executing the above command, the Apache is active and running properly.

Step 4: Configure Firewall

To configure the firewall for Apache and allow full access, run the following command:

sudo ufw allow 'Apache Full'

Using the command followed by “Apache Full” allows Apache to have full control of your Ubuntu system.

Step 5: Enable Firewall

After configuring the firewall, run the “ufw enable” command to activate the firewall on your system:

sudo ufw enable

The output indicates that the firewall is active now.

Step 6: Confirmation

Check the status of the firewall by using the command provided below:

sudo ufw status

You can see in the above screenshot that the firewall status is active and Apache has allowed full control.

Step 7: Test Apache

You can test the Apache services both from the command line and by launching through a web browser. To test from the terminal execute the command attached below:

xdg-open http://localhost

The following Apache2 default page will be displayed on your screen if the above steps are properly followed:

The Apache2 default page shows that Apache2 has been successfully installed on your Ubuntu 22.04 system.


Execute a single line command “sudo apt install apache2 -y” to install Apache on Ubuntu 22.04. Apache offers a powerful toolkit for managing web servers on your local machine. In the learning-based post, we have provided you a detailed insight on how to install and configure Apache services on Ubuntu 22.04.

Print Friendly, PDF & Email