How to Install Apache on CentOS 7

The Apache web server is one of the most popular and powerful web servers in the world, due to its ease of administration and flexibility. In this tutorial we will install Apache on a server that doesn’t have a web server or database server already installed.

Pre-Flight Check
  • These instructions are intended for installing Apache on a single CentOS 7 node.

Step 1: Install Apache

First, clean-up yum:

  • sudo yum clean all

As a matter of best practice we’ll update our packages:

  • sudo yum -y update

Installing Apache is as simple as running just one command:

  • sudo yum -y install httpd

Step 2: Allow Apache Through the Firewall

Allow the default HTTP and HTTPS port, ports 80 and 443, through firewalld:

  • sudo firewall-cmd --permanent --add-port=80/tcp
  • sudo firewall-cmd --permanent --add-port=443/tcp

And reload the firewall:

  • sudo firewall-cmd --reload
Step 3: Configure Apache to Start on Boot

And then start Apache:

  • sudo systemctl start httpd

Be sure that Apache starts at boot:

  • sudo systemctl enable httpd

To check the status of Apache:

  • sudo systemctl status httpd

To stop Apache:

  • sudo systemctl stop httpd
  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

Initial Server Setup with CentOS 7

Initial Server Setup with CentOS 7  Introduction When you first create a new server, there are...

How To Create an SSL Certificate on Apache for CentOS 7

How To Create an SSL Certificate on Apache for CentOS 7  Introduction TLS, or "transport layer...

How to Install and Configure phpMyAdmin on CentOS 7

phpMyAdmin is an open source tool used for the administration of MySQL. In addition to offering...

How To Set Up Apache Virtual Hosts on CentOS 7

Introduction The Apache web server is the most popular way of serving web content on the...

How To Connect To Your Droplet with SSH

How To Connect To Your Droplet with SSH  Introduction If you have recently created a...