How to Install Apache Web Server on CentOS 7

Idriss Fofana
2 min readJan 16, 2022

--

Apache is a Linux application for running web servers. It is part of the LAMP (Linux, Apache, MyPHP, and PHP) stack a package of applications that form the basis for most web technology. It is an open-source software that allows you to to deploy your website in just a few steps.

Prerequisites

  • CentOS 7 server
  • Access to a command line terminal
  • A user account with sudo privileges

FYI : Make sure you “ssh” ,using you server “username” and the “public IP address” then the “password”.

Installing Apache on CentOS

Step 1: Update Software

To Make sure you are using the latest versions of the software, input the command:

sudo yum -y update

The system should reach out to the software and update the list to the latest versions. The “-y” is to avoid being asked if you would like to proceed with the command. it is to save a little time. You can use sudo yum update then type “yes” when asked.

Step 2: Install Apache

To install Apache on your CentOS 7, use the following command:

sudo yum -y install httpd

The system should download and install the Apache software packages. “Complete!” will display on the screen

Step 3: Activate Apache

To activate Apache, start its service first.

1. Enter the following command in a terminal window:

sudo systemctl start httpd

This will start the Apache service.

2. Next, set the Apache service to start when the system boots:

sudo systemctl enable httpd

Step 4: Verify Apache Service

Display information about Apache, and verify it’s currently running with:

sudo systemctl status httpd

Step 5: Configure firewall to Allow Apache Traffic

Normal web traffic uses the http protocol on Port 80, while encrypted web traffic uses the https protocol, on Port 443.

1. Modify your firewall to allow connections on port 80 using the following command:

sudo firewall-cmd — zone=public––permanent ––add-port=80/tcp

2. Once it is done, reload the firewall to apply the changes with the command:

sudo firewall-cmd ––reload

Step 6: Test it out

Enter command:

curl -4 icanhazap.com

Enter the IP address into your web browser to view the test page.

This shows that you have successfully installed Apache on your CentOS 7 server.

--

--