Install Apache on CentOS/Ubuntu

Install Apache on CentOS/Ubuntu

In this post we will learn how to install Apache on CentOS and Ubuntu Server. I will be using CentOS 7 and Ubuntu-20.04

First we will be updating the packages already present on the OS and perform a reboot.

This part is dedicated to the CentOS

Update all packages

yum update -y
reboot

Install Apache

yum install httpd -y

Check status of httpd

systemctl status httpd

Start Apache and Check status

systemctl start httpd
systemctl status httpd

Allow Apache through Firewall

firewall-cmd --permanent --add-service=http

Restart firewalld service.

systemctl restart firewalld

Check firewall rules.

firewall-cmd --list-all

Enable Apache at startup

systemctl enable httpd

This part is dedicated to the Ubuntu

Update all packages

apt update && apt upgrade -y
reboot

Install Apache

apt install apache2 -y

Check status of apache2

systemctl status apache2

As shown in the screenshot above, Apache is already started and enabled at boot