How to Install Apache on CentOS 8

Install Apache on CentOS 8

In this article, we will have explained the necessary steps to install and configure Apache on CentOS 8. Before continuing with this tutorial, make sure you are logged in as a user with sudo privileges. All the commands in this tutorial should be run as a non-root user.

Apache HTTP Server, also known as “Apache.” It is a web server famous for promoting the growth of the World Wide Web. Apache is an open-source, cross-platform, powerful, stable, reliable, and free web server providing features that can be extended by a wide variety of modules. It is also used as a reverse proxy server in different scenarios.


  • Operating System with CentOS 8
  • Server IPv4 Address with Superuser Privileges (Root Access)
  • Gnome Terminal for Linux Desktop
  • PuTTy SSH client for Windows or macOS
  • Powershell for Windows 10/11
  • Familiar with APT Commands

Install Apache on CentOS

Step 1. The first command will update the package lists to ensure you get the latest version and dependencies.

sudo yum update

Step 2. Install Apache on CentOS 8.

Apache is available in the default CentOS repositories, run the following command to install Apache:

sudo yum install httpd

Run and enable the Apache webserver to start after reboot:

sudo systemctl enable httpd
sudo systemctl start httpd

You can also check the version of your web server in order to make sure that it was installed correctly:

httpd -v

Following are the Apache important files and directories:

  • All Apache configuration files are located in the /etc/httpd directory.
  • The main Apache configuration file is /etc/httpd/conf/httpd.conf.
  • Configuration files ending with .conf located in the /etc/httpd/conf.d directory are included in main Apache configuration file.
  • Configuration files that are responsible for loading various Apache modules 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.
  • – It is a good practice to follow a standard naming convention. For example, if the domain name is then the configuration file should be named
  • Apache log files (access_log and error_log) are located in the /var/log/httpd/ directory. It is recommended to have a different access and error log files for each vhost.

Step 3. Adjust the Firewall for Apache Web Server.

During the installation, Apache creates firewalld service files with predefined rules for allowing access to HTTP (80) and HTTPS (443) ports:

sudo firewall-cmd --permanent --zone=public --add-service=http
sudo firewall-cmd --permanent --zone=public --add-service=https
sudo firewall-cmd --reload

That’s all you need to do to Install Apache Web Server on CentOS 8. I hope you find this quick tip helpful. If you have questions or suggestions, feel free to leave a comment below.