How to Install Apache Server in Ubuntu 22.04?

Jun 21, 2022 . Admin

Hi Guys,

Here, I will show you how to works ubuntu 22.04 install apache server. you can understand a concept of ubuntu 22.04 install web server. if you want to see example of how to install apache server in linux step by step then you are a right place. I explained simply step by step install an apache web server in ubuntu 22.04.

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.

(1). Install Apache 2 on Ubuntu

(2). Setup Firewall with UFW on Ubuntu

(3). Managing the Apache Process

Step 1: Connect Your AWS EC2 Intance from SSH

You can read this tutorial "Commands to Install Apache Web Server on Ubuntu 22.04 or 20.04" and connect your ec2 instance to ssh.

Step 2: Update Ubuntu System Repositories

Start your ssh terminal and type the following command:

sudo apt update  
Step 3: Install Apache 2

Run the following sudo command to install Apache 2.

sudo apt install apache2  

A prompt box will open with the "Y / N" option to continue the installation.

Enter Y,after which the installation process start.

Step 4: Verify the Apache installation

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

apache2 -version 

If you would like to access it from outside. So, you wish to update firewall settings on your apache 2 web server on your Ubuntu 20.04 EC2 instance.

Setup Firewall with UFW on Ubuntu Step 1: List the UFW application profiles

In this step, open your terminal ssh and kind the subsequent command to list such available firewall ufw applications :

sudo ufw app list

Then you will see a list of the application profiles:

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

As indicated by the output, there are three profiles 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

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

sudo ufw allow 'Apache Full'

You can verify the change by typing:

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, open your browser and sort your AWS ec2 instance IP address. And, it'll be feels like the Apache 2 page within the following picture:

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

Now that you just have your web server up and running, let’s re-examine some basic management commands using systemctl..

To stop your web server, type:

sudo systemctl stop apache2

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

sudo systemctl start apache2

To stop and then start the service again, type:

sudo systemctl restart apache2

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

sudo systemctl reload apache2

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

sudo systemctl disable apache2

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

sudo systemctl enable apache2

Apache should now start automatically when the server boots again.

Conclusion

Install apache on AWS ec2 instance ubuntu tutorial, You have learned how to install apache 2 on aws ec2 ubuntu.

#Ubuntu