
Apache HTTP server is one of the most popular web servers in the world. It’s free and open-source cross-platform web server software developed and maintained by Apache Software Foundation. Apache is a easy to learn and configure that providing an ability to host websites mainly via HTTP or HTTPS protocols. In RHEL based distribution Apache webserver is know under name httpd
. In this article, we’ll explain how to install and manage the Apache webserver on CentOS 8.
Install Apache on CentOS 8
CentOS default repositories includes Apache package and it’s installation is very straight forward.
To install the Apache run the following command as root or user with sudo privileges:
sudo yum install httpd
Enable and start the Apache server once the installation has been finished:
sudo systemctl enable httpd
sudo systemctl start httpd
Verify the service is running by checking status:
sudo systemctl status httpd
It should look something like below:
● httpd.service - The Apache HTTP Server Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled) Active: active (running) since Fri 2019-12-29 13:57:28 UTC; 28s ago …
Adjust Firewall
At the time of installation, Apache creates firewalld service files with predefined rules for allowing access to HTTP (80
) and HTTPS (443
) ports.
If your firewall enabled then you have to open http
and https
ports. Use below commands to open 80
and 443
ports:
sudo firewall-cmd --permanent --zone=public --add-service=http
sudo firewall-cmd --permanent --zone=public --add-service=https
sudo firewall-cmd --reload
Testing Apache Installation
Finally you installed Apache and adjusted firewall so you can check version of Apache service by type:
sudo httpd -v
Server version: Apache/2.4.37 (CentOS) Server built: Jul 30 2019 19:56:12
Afterwards, you can do final testing to know everything is working proper, open browser and browse with your server public ip address. It should show a CentOS Apache default page as below:
http://YOUR_SERVER_IP

Manage Apache Configuration
Following information shows that how Apache configuration files are structured and managing the Apache web server.
- The
/etc/httpd
directory is the default location for the all Apache configuration files. - The main Apache configuration file is
/etc/httpd/conf/httpd.conf
- All the files located at
/etc/httpd/conf.d
directory and ending with.conf
are included by default in main Apache configuration file. - Various Apache modules configuration files are located in the
/etc/httpd/conf.modules.d
directory. - Apache
vhost
files must end with.conf
and be stored in/etc/httpd/conf.d
directory. You can have as many vhosts as you need. Creating a separate configuration file (vhost) for each domain makes the server easier to maintain. - Apache vhost files must end with
.conf
and be stored in/etc/httpd/conf.d
directory. You can have as many vhosts as you need. Creating a separate configuration file (vhost) for each domain makes the server easier to maintain. - It is good practice to follow naming standard for the configuration files. For example, if the domain name is
tecnstuff.net
then the configuration file should be namedtecnstuff.net.conf
- The
/var/log/httpd/
directory contains the Apache log files (access_log
anderror_log
). It’s also advised to have a different access and error log files for each vhost. - You can set any directory as your document root directory. Following are the common and mostly used locations for the webroot:
/var/www/html/yourdomain.com
/var/www/yourdomain.com
/home/username/yourdomain.com
Conclusion
You have successfully installed Apache on your CentOS 8 server. You can now configure your virtual hosts and can deploy your applications.
If you have any trouble in installing and configuring Apache, please leave a comment below.
Leave a Reply