how to install apache on ubuntu

How to install apache on ubuntu ?

The Apache HTTP server is the most widely-used web server in the world. It is having vast features at control level. You will see all features with time

Let us go step by step on  how to install an Apache on Ubuntu  20.04 server.

Step 1 : We should have the root credentials for server .

Step 2 : Create the new user with below command as we should not login from root credential

adduser <username>

This will add user and will ask for password . Set a strong password for user

Some information is not mandatory here so you can skip that by pressing enter only

Step 3 : Grant Admin Previleges

Add user to sudo group by below command

usermod -aG sudo <username>

Now <username> has right to perform all admin activities but with sudo keyword

Step 4 : Firewall Setting

Ubuntu UFW firewall just allow few services to run

Step 5 : run below command to see available applications

ufw app list

Step 6 : allow ssh connection so that user can log back

ufw allow OpenSSH

Output will be

Rules Updated

Rules Updated ( V6)

Step 7 : Enable the firewall

ufw enable

Now firewall is allowing only SSH connections. So whenever we are going to install any additional service then we need to set firewall setting.

Step 8  check the firewall Status

ufw status

Step 9 : just check user access on new terminal by running following command

ssh <username>@serverip

step 10 : just check the latest package index by below command

sudo apt update

Step 11 : Apache is available in ubutu repository so by below command we can install apache on ubuntu server

sudo apt install apache2

Accept the installation and Apache will be installed with all dependencies

Step 12 : We need to set some firewall settings so that public user can access the port .

Fetch the list of UFW application by below command

sudo ufw app list

In my case i got below list

Available applications:
  Apache
  Apache Full
  Apache Secure
  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 13 : So we need to enable most safe and restrictive profile. So lets do this by below command

sudo ufw allow ‘Apache’

Step 14 : Lets verify the change

sudo ufw status

Here in output you can see we have anywhere access of apache and apache(v6)

Step 15: Lets test the apache web server

sudo systemctl status apache2

Step 16. Lets see some basic command on apache

How to stop apache process

sudo systemctl stop apache2

How to start apache process

sudo systemctl start apache2

How to restart apache process

sudo systemctl restart apache2

In case of activation of only config changes you may need to reload apache so that connection should not drop

sudo systemctl reload apache2

By Default Apache services started automatically on reboot but if you want to disable it

sudo systemctl disable apache2

To enable apache service on startup

sudo systemctl enable apache2

 

* The Content stated above is for informational purpose only. Expert Software Team is not responsible if any part of content found meaningless in any manner or condition.

Leave a Reply

Your email address will not be published. Required fields are marked *