---
title: "How to Install Apache on CentOS 7"
description: "To set up your CentOS 7 web server, the first thing you need to do is install a web server program such as Apache. This program will act as a handler for your incoming and outgoing data and allow..."
url: https://www.inmotionhosting.com/support/server/apache/how-to-install-apache-on-centos-7/
date: 2020-04-30
modified: 2024-03-21
author: "InMotion Hosting Contributor"
categories: ["Apache"]
type: post
lang: en
---

# How to Install Apache on CentOS 7

To set up your **CentOS 7** web server, the first thing you need to do is install a web server program such as **Apache**. This program will act as a handler for your incoming and outgoing data and allow users to connect to your web server. While there are a number of different web server software options, Apache is one of the most commonly used. In this guide, we will cover how to install Apache on a CentOS 7 server **[via SSH](https://www.inmotionhosting.com/support/server/ssh/how-to-login-ssh/)**. Please note that you will require [root access](https://www.inmotionhosting.com/support/amp/obtain-root-access/) to complete this guide.

**Notice:** CentOS Linux 7 will reach end of life (EOL) on June 30, 2024.

Topics Include:

- [Installing Apache](#install)
- [Managing Apache](#manage)
- [Installing firewalld](#firewalld)
- [Testing Apache](#test)

## **Installing Apache**

1. Before you can install Apache, you will want to make sure the package is fully-up-to-date. To to do this, run the following command: $ sudo yum update httpd
2. Once the package has been updated, start the installation process with the following command: $ sudo yum install httpdAt two different points you will be prompted to press a key to confirm. Press the **Y key** and hit **enter** both times. 
3. Once the installation process has finished, you will need to start the Apache service. To do this, run the following command: $ sudo systemctl start httpd
4. To confirm that Apache was installed successfully, check the service status by running the following command: $ sudo systemctl status httpd
5. The output will tell you whether or not the service is running as well as other details about its performance. If the output says Apache is **active**, that means your Apache installation was successful.

## **Managing Apache**

### **Restart Service**

Occasionally, making changes to your server may require restarting Apache services. To do this, run the following command:

$ sudo systemctl restart httpd

### **Reload Service**

To restart the Apache service without dropping current connections, run the following command:

$ sudo systemctl reload httpd

## **Installing firewalld and Opening Ports**

Before Apache can accept connections over the public internet, you will need to install the **firewalld** service and open the firewall ports commonly used for internet traffic. 

1. First, install firewalld via the following command:yum install firewalldThe installation will prompt you to input a key to continue. Press the **Y key** and hit **enter**.
2. Next, open up **HTTP traffic** on **Port 80** via the following command:sudo firewall-cmd --permanent --add-service=httpIf you want to enable connections via the **HTTPS protocol**, use the following command to open **Port 443**: sudo firewall-cmd --permanent --add-service=https
3. Last, restart the Apache service with the following command:sudo systemctl restart httpdYour firewall should now be configured and listening for connections over **HTTP** and **HTTPS**. 

## **Testing Apache**

In order to confirm that Apache was installed and configured properly, you will want to perform a quick test. This will make sure that your server is capable of accepting connections over the public internet. 

1. 1. First, you need to find the server’s IP address, to do this, run the following command: hostname -I
2. Next, input the IP address into your web browser with the https:// protocol as follows:https://12.34.567.89
3. Your browser should then take you to the following splash page:[![ApacheSplashPage](/support/wp-content/uploads/2020/04/apachetest.png)](/support/wp-content/uploads/2020/04/apachetest.png)

Congratulations, you have now learned how to install Apache on your CentOS server! Manage Apache on your [Dedicated Hosting](https://www.inmotionhosting.com/dedicated-servers) server to give your users a secure and reliable experience!
