How to install Apache Web Server on CentOS 7

In this article, we will install the Apache HTTP Server on CentOS 7. Apache HTTP Server is a free and open-source cross-platform web server, that we can install on different Operating Systems.


To install Apache Web Server we just required a few packages and the user with root privileges. Let’s start installing the Apache Web Server.

Step 1: Installing Apache HTTP Server Packages

In this step, we will update the software packages to the latest version, and install the required packages for the Apache web server.

Wait for a couple of minutes till the package updates are completed.

Now, execute the below command to install the Apache Web Server packages:

It will initiate the installation of the Apache packages from the default software repositories of CentOS using the YUM package manager.

Please Yes to continue the installation process

Step 2: Allowing the HTTP/HTTPD traffic

By default, the web traffic, i.e, HTTP/HTTPD is blocked. We have to manually allow the traffic to use the Web Server from external network hosts.

You can use the below command to configure CentOS firewall rules to allow the traffic.

Step 3: Managing the Apache Web Server

By default, after installing the apache server, it will be disabled. You have to start it manually to start working with Apache Web Server.

To check the current state of the HTTPD server, you can use the below command:

You will get the below results

To start the apache web server, you can use the below command

The above command will start the HTTPD service. Now, if you again check the HTTPD status with the status command, you will find that the apache server is now up and running:

Step 4: Initial testing of Apache Web Server

We have done the required configuration for the apache web server. Now, you need to simply browse the web server either via IP address or with configured FQDN. You should get a page similar to the below screenshot.


That’s it! We have successfully configured Apache Web Server on CentOS 7. You may further edit /var/www/html/ directory as suggested on Welcome Page, to install your content.

Step 5: Configuring HTTPS access to the web server

You might notice, even after configuring all of the configurations, you can only able to access the HTTP mode of the web server. If you try to open the default web page using https://xx.xx.xx.xx/, you will get an error.

This is because the required SSL certificate and ssl.conf file is missing. You have to install the ssl_mod package in the newly installed CentOS machine.

You can simply run the below command to install the ssl_mod package in CentOS:

Once, the ssl_mod package is installed, you need to reload the HTTPD service to browse the web page using HTTPS, i.e., secure HTTP. You can reload the httpd service using the below command:

Since it is a default certificate, you will still get a Certificate Warning page while accessing the web page. To make it more secure, you can either create a SAN certificate CSR or you can simply generate and install a self-signed certificate.


Related Articles


Apache is an open-source cross-platform popular web server. We have installed the web server in CentOS 7. We have started the httpd service and we allowed HTTP traffic on the CentOS firewall.

Hope you like this article. In case you like this article, request you to please share it on social media platforms! In case you get into error, just comment in the comment box!

Leave a Reply

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