Install Apache on CentOS / RHEL 8
In this tutorial, I’m going to show how to install Apache on CentOS or RHEL 8. Very easy to setup. Let’s follow these steps:
Table of Contents
Step 1 : Install, Enable and Start Apache
On CentOS / RHEL 8, we will use the dnf
command to install any package. Before installing Apache, let’s upgrade our operating system by this command:
sudo yum update
Now, let’s install Apache:
sudo dnf install httpd
We need to enable the Apache server to start after reboot:
sudo systemctl enable httpd
To start the Apache server, run this command:
sudo systemctl start httpd
Step 2 : Open HTTP & HTTPS Port
If firewall is enabled on your server, you need to open HTTP (80) port. Let’s open HTTP and HTTPS (443) ports:
# open http
sudo firewall-cmd --zone=public --permanent --add-service=http
# open https
sudo firewall-cmd --zone=public --permanent --add-service=https
# reload firewall
sudo firewall-cmd --reload
Step 3 : Print Welcome Message
We’ve installed Apache webserver on our server. Let’s print a welcome message. Just run this command:
echo "Welcome to CentOS/RHEL 8 Server" > /var/www/html/index.html
Open browser and visit the website using the IP address or hostname. Here’s the example http://140.82.2.182
. You’ll see the welcome message.
Md Obydullah
Software Engineer | Ethical Hacker & Cybersecurity...
Md Obydullah is a software engineer and full stack developer specialist at Laravel, Django, Vue.js, Node.js, Android, Linux Server, and Ethichal Hacking.