How to Install and Configure Apache on Ubuntu 22.04 LTS?

Jul 19, 2022 . Admin

Hi Guys,

In this quick example, let's see How to Install and Configure Apache on Ubuntu 22.04 LTS?. In this article, we will implement a Install and Configure Apache - Ubuntu. we will help you to give example of Installing the Apache Server on Ubuntu 22.04. you'll learn Step-By-Step Procedure To Install Apache From Source Code. You just need to some step to done Installation Apache Guide for Ubuntu.

You can use this post for ubuntu 14.04, ubuntu 16.04, ubuntu 18.4, ubuntu 20.04, ubuntu 21 and ubuntu 22.04 versions.

Step 1: Install Apache on Ubuntu

Press “CTRL+ALT+T” to open the terminal and run the below-given command to update system repositories:

$ sudo apt update

After updating system repositories, write out the following command for installing the “apache2” on your Ubuntu 22.04 system:

 
$ sudo apt install apache2
Step 2: Check Apache Status

the web server service should be started automatically, You can check the Apache service status :

sudo systemctl status apache2
Output

apache2.service - The Apache HTTP Server
   Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
  Drop-In: /lib/systemd/system/apache2.service.d
           `-apache2-systemd.conf
   Active: active (running) since Sun 2018-12-31 05:18:45 PDT; 2min 30s ago
 Main PID: 3143 (apache2)
    Tasks: 55 (limit: 2321)
   CGroup: /system.slice/apache2.service
           |-3143 /usr/sbin/apache2 -k start
           |-3144 /usr/sbin/apache2 -k start
           `-3145 /usr/sbin/apache2 -k start
Step 3: Firewall setup

We will utilize the “Apache Full” profile for enabling network activities on the port “80”:

$ sudo ufw allow 'Apache Full'

After doing so, check the current firewall status:

$ sudo ufw status
Output

Status: active

To                         Action      From
--                         ------      ----
22/tcp                     ALLOW       Anywhere
Apache Full                ALLOW       Anywhere
22/tcp (v6)                ALLOW       Anywhere (v6)
Apache Full (v6)           ALLOW       Anywhere (v6)
Step 4: Test Install Apache Web Server on Ubuntu
http://your_server_ip
Step 5: Manage the Apache services

Now that you have your web server up and running, let’s review some basic management commands using systemctl. To stop your web server, run:

To stop your web server, run:

$ sudo systemctl stop apache2

To start the web server when it is stopped, run:

$ sudo systemctl start apache2

To stop and then start the service again, run:

$ sudo systemctl restart apache2

If you are simply making configuration changes, Apache can often reload without dropping connections. To do this, use the following command:

$ sudo systemctl reload apache2

By default, Apache is configured to start automatically when the server boots. If this is not what you want, disable this behavior by running:

$ sudo systemctl disable apache2

To re-enable the service to start up at boot, run:

$ sudo systemctl enable apache2

To Check Apache Status :

$ sudo systemctl status apache2
Step 6: Apache configuration file

Now that you know how to manage the Apache service itself, you should take a few minutes to familiarize yourself with a few important directories and files.

(1). /etc/apache2/httpd.conf
(2). /etc/apache2/apache2.conf
(3). /etc/httpd/httpd.conf
(4). /etc/httpd/conf/httpd.conf	
#Ubuntu