How To Install the Apache Web Server on CentOS 8

How To Install the Apache Web Server on CentOS 8

Introduction

The Apache HTTP server is the most widely-used web server in the world. It provides many powerful features including dynamically loadable modules, robust media support, and extensive integration with other popular software.

In this tutorial, you will learn how to install an Apache web server on your CentOS 7 server.

Installation of Apache package

First and foremost make sure your server is up to date using the command yum update, this will update and install any relevant packages found, the -y option, will install the packages automatically without asking you.

yum update -y

2021-09-26_14h51_34.png

Use the command yum install httpd to install Apache web server from the default software repositories.

yum install httpd -y

2021-09-26_14h53_16.png

Checking your Web Server

Apache does not automatically start on CentOS once the installation completes. You will need to start the Apache process manually:

Status Apache

Use the command systemctl status httpd to check the status.

systemctl status httpd

2021-09-26_14h56_11.png

Start Apache

To start Apache, use the command systemctl start http. After starting Apache, use the status command to Check the status again and it should look more or less like the picture below.

systemctl start http

2021-09-26_14h58_51.png

Enable Apache

Enable the Apache service so that it can automatically start after a Reboot using systemctl enable httpd.

systemctl enable httpd

2021-09-26_15h12_10.png

Allowing Apache in your firewall

By default, CentOS 8 comes with Firewalld as a firewall and all ports are closed in it. To open the http-(80) and https-(443) ports, use the commands below:

firewall-cmd --zone=public --permanent --add-service=http
firewall-cmd --zone=public --permanent --add-service=https
firewall-cmd --reload

After the firewall reloads, you are ready to start the service and check the web server.

2021-09-26_15h04_03.png

Checking your web server

You can access the default Apache landing page to confirm that the software is running properly through your IP address. If you do not know your server’s IP address, you can get it a few different ways from the command line.

Use the commands hostname -I, ifconfig , ip a to get your server's IP address.

hostname -I
ifconfig
ip a

Testing Apache

To verify Apache web server functionality, we can open a browser on your browser's address bar and enter http ://your_Server_IP, a default web page of Apache should appear as the following.

http://your_server_ip

2021-09-26_15h15_32.png

Hope you like the article. Stay Tuned for more.

Thank you.