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 -yrebootInstall Apache
yum install httpd -y
Check status of httpd
systemctl status httpd
Start Apache and Check status
systemctl start httpdsystemctl status httpd
Allow Apache through Firewall
firewall-cmd --permanent --add-service=httpRestart firewalld service.
systemctl restart firewalldCheck firewall rules.
firewall-cmd --list-all
Enable Apache at startup
systemctl enable httpdThis part is dedicated to the Ubuntu
Update all packages
apt update && apt upgrade -yrebootInstall Apache
apt install apache2 -yCheck status of apache2
systemctl status apache2
As shown in the screenshot above, Apache is already started and enabled at boot