December 23, 2024
Tutorials

How to Install Apache Web Server on Ubuntu 22.04

How to Install Apache Web Server on Ubuntu 22.04

The Apache HTTP Server, commonly referred to as Apache, is one of the world’s most popular open-source web servers. Its primary purpose is to serve web content to clients, such as web browsers when they request web pages or other resources over the internet. Apache is known for its stability, reliability, and flexibility. That’s why it is the best pick for hosting websites and web applications on Linux systems, including Ubuntu.

This post will list the method to install Apache Web Server on Ubuntu 22.04 (the latest LTS of Ubuntu).

How to Install Apache Web Server on Ubuntu 22.04?

Apache Web Server support is available on the apt repository of Ubuntu 22.04. Let’s dig into the steps and the commands to get it on your Ubuntu 22.04:

Update the Packages List

Let’s first refresh the packages list on the Ubuntu 22.04:

$ sudo apt update

A computer screen with white text

Description automatically generated

Install the Apache

Once you get the updated packages, use the command below to install Apache on Ubuntu 22.04:

$ sudo apt install apache2

Verify the Installation

Once done with the installation, check the installed version of Apache to verify the installation:

$ apache2 -v

A close up of a screen

Description automatically generated

The output shows the server version 2.4.52 and the server built as well.

How to Configure Apache Web Server on Ubuntu 22.04?

Apache, like any web hosting server, must deal with the incoming and outgoing traffic. Thus, it is mandatory to allow operations of Apache through your Firewall. Moreover, Apache is managed by the backend service on Ubuntu 22.04. Therefore, the service must also be configured properly for smooth operations of Apache 2 on your Ubuntu 22.04. Let’s do all these configurations step by step, as follows:

Configure the Firewall

Use the UFW utility to allow Apache on Firewall, which can be done using the command:

$ sudo ufw allow ‘apache full’

Reload the Firewall to make the changes effective:

$ sudo ufw reload

Lastly, it is recommended to check the status of the active services through Firewall:

$ sudo ufw status

A screenshot of a computer

Description automatically generated

Note: If you cannot make changes using UFW, the utility might be disabled. In such a scenario, you need to enable it via the command:

$ sudo ufw enable

Manage the Backend Apache Services

Now, it is time to configure the backend Apache services. The users can use the systemctl utility, and the following commands can be used:

Start the Apache Service

Initially, the Apache service might not be working. To make it functional, start the service using the command:

$ sudo systemctl start apache2

Enable the Service

Enabling the Apache service will keep the service in the active state even after the reboot:

$ sudo systemctl enable apache2

A screenshot of a computer

Description automatically generated

Check the Status

While dealing with the Apache service, the users must keep on tracing the status of the service, which can be done using the command:

$ sudo systemctl status apache2

A computer screen shot of a program

Description automatically generated

Stop the Service

If the service needs to be stopped, the following stop option of the systemctl command can be used:

$ sudo systemctl stop apache2

Disable the Service

Sometimes, you might need to disable the Apache service. The service can be disabled via the command:

$ sudo systemctl disable apache2

A screenshot of a computer

Description automatically generated

That’s how you can configure the Firewall and Apache backend service.

How to Test the Working of the Apache on Ubuntu 22.04?

Once the Apache is installed and the service is configured, you can test the working of the Apache on your system. Go to your browser and test the localhost (127.0.0.1 in our case) on the browser’s address bar. You will be welcomed by the Apache as shown below:

How to Remove Apache From Ubuntu 22.04?

Apache Web Server is not the package to be removed without any reason. If you are in need to remove it from Ubuntu 22.04, you can do it using the command:

$ sudo apt autoremove apache2

Bottom Line

Apache Web Server is the leading multipurpose web hosting software for Ubuntu and other Linux distributions. Apache services can be obtained on Ubuntu 22.04 by installing the Apache server. Apart from only installation, the user needs to configure the Firewall and manage the Apache backend service to make it functional.

In the end, this post has covered you all, including installing and configuring Apache Web Server on Ubuntu 22.04. In our next article, read How to Setup Apache Virtual Hosts on Ubuntu 22.04.

Leave feedback about this

  • Quality
  • Price
  • Service

PROS

+
Add Field

CONS

+
Add Field
Choose Image
Choose Video