Home Ubuntu How To Install Apache Web server on Ubuntu 22.04 ?

How To Install Apache Web server on Ubuntu 22.04 ?

by Shahriar Sagor

Hello dev’s today now in this post i will show you How To Install Apache Web server on Ubuntu 22.04 ?Her in this article i will be focused on how we can install apache server in ubuntu 22.04? So from here you can learn about ubuntu 22.04 install apache server. Here I will be details explain this with simply about ubuntu 22.04 install web server. Now in this example i will help you how to install apache server in linux step by step.

Install Apache Web server Install

we can also use this post for any version ubuntu 14.04, ubuntu 16.04, ubuntu 18.4, ubuntu 20.04, ubuntu 21 and ubuntu 22.04.

  • Install Apache 2 on Ubuntu
  • Setup Firewall with UFW on Ubuntu
  • Managing the Apache Process
Step 1: Connect Your AWS EC2 Intance from SSH

We can connect your ec2 instance to ssh.

Step 2: Update Ubuntu System Repositories

Now need to Start our ssh terminal and type the following command:

sudo apt update  
Step 3: Install Apache 2

Then need to run the following sudo command to install Apache 2.

sudo apt install apache2  

Now in the prompt box will be open with the “Y / N” option to continue the installation.

Need to Enter Y,after which the installation process start.

Step 4: Verify the Apache installation

Now need to Type the following command to check if Apache 2 is installed:

apache2 -version 

If we will like to access it from the outside. So, we wish to update the firewall settings on our apache 2 web server on our Ubuntu 20.04 EC2 instance.

Setup Firewall with UFW on Ubuntu

Step 1: List the UFW application profiles

Now in this step, need to open our terminal ssh and kind the subsequent command to list such available firewall of ufw applications :

sudo ufw app list

Then we will see the list of the application profiles:

  1. OutputAvailable applications:
  2. Apache
  3. Apache Full
  4. Apache Secure
  5. OpenSSH

As the indicated by the output, there are three profiles is available for Apache:

Apache : This profile opens only port 80 (normal, unencrypted web traffic)
Apache Full : This profile opens both port 80 (normal, unencrypted web traffic) and port 443 (TLS/SSL encrypted traffic)
Apache Secure:This profile opens only port 443 (TLS/SSL encrypted traffic)
Step 2: Allow Apache Full on UFW

For Use the following UFW command to allow the Apache Flower by subsequent command:

sudo ufw allow 'Apache Full'

we can verify the change by typing this command:

sudo ufw status

The output will provide a list of allowed HTTP traffic:

1 :   OutputStatus: active
2 : 
3 :   To                         Action      From
4 :   --                         ------      ----
5 :   OpenSSH                    ALLOW       Anywhere                  
6 :   Apache                     ALLOW       Anywhere                
7 :   OpenSSH (v6)               ALLOW       Anywhere (v6)             
8 :   Apache (v6)                ALLOW       Anywhere (v6)
Step 3: Verify that the Apache service is running
sudo systemctl status apache2

Finally, need to open our browser and sort our AWS ec2 instance IP address. And then, it’ll be feels like the Apache 2 page :

install apache 2 web server on amazon ec2
Managing the Apache Process

Now that we just need on our web server up and running, let’s re-examine some the basic management commands by using systemctl..

To stop our web server, type:

sudo systemctl stop apache2

To start the web server when it will be stopped, type:

sudo systemctl start apache2

For stop and then start the service again, type:

sudo systemctl restart apache2

If you’re simply making the configuration changes, Apache can often reload without the dropping connections. To do this, need to use this command:

sudo systemctl reload apache2

By default, Apache is configured to begin automatically when the server is boots. If this can be not what we wish, disable this behavior by typing this command:

sudo systemctl disable apache2

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

sudo systemctl enable apache2

This will be Apache should now start automatically when the server boots again.


That’s all for Install apache on AWS ec2 instance ubuntu tutorial, from here we learned how to install apache 2 on aws ec2 ubuntu.

Read Also: How To Change phpMyAdmin Login URL Ubuntu Apache 22.04 ?

Thanks for read. I hope it help you. For more you can follow us on facebook


You may also like