Md Obydullah Follow I'm Md Obydullah. I build open-source projects and write about Laravel, Linux server, modern JavaScript and web development.

Install Apache on CentOS / RHEL 8

Published on October 16, 2019 45 sec read

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

  1. Install, Enable and Start Apache
  2. Open HTTP & HTTPS Port
  3. Print Welcome Message

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.

The article is over. Thank you. 🙂

You're welcome to suggest any article to write!

Md Obydullah Follow I'm Md Obydullah. I build open-source projects and write about Laravel, Linux server, modern JavaScript and web development.

Leave a Reply

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