# How to Install Apache on CentOS
In this article, I’ll explain how to install and manage the Apache webserver on CentOS 8.
# Installing Apache
Apache is available in the default CentOS repositories, and the installation is pretty straight forward.
On RHEL based distributions, the Apache package and service are called httpd. To install the Apache run the following command as root or user with sudo privileges
sudo yum install httpd
Once the installation is complete, enable and start the Apache service
sudo systemctl enable httpd sudo systemctl start httpd
To verify that the service is running, check its status
sudo systemctl status httpd
# Adjusting the Firewall
FirewallD is the default firewall solution on Centos 8.
During the installation, Apache creates firewalld service files with predefined rules for allowing access to HTTP (80) and HTTPS (443) ports.
The following commands will permanently open the necessary ports
sudo firewall-cmd --permanent --zone=public --add-service=http sudo firewall-cmd --permanent --zone=public --add-service=https sudo firewall-cmd --reload
# Managing Apache
This section explains how the Apache configuration files are structured and the best practices for managing the Apache webserver.
- All Apache configuration files are located in the
- The main Apache configuration file is
- Configuration files ending with
.conflocated in the
/etc/httpd/conf.ddirectory are included in main Apache configuration file.
- Configuration files that are responsible for loading various Apache modules are located in the
- You can set your domain document root directory to any location you want. The most common location for webroot is
It is a good practice to follow a standard naming convention. For example, if the domain name is mydomain.com then the configuration file should be named mydomain.com.conf