How to Install Apache on CentOS 8

How to Install Apache on CentOS 8

Apache is the web server that processes requests and serves web assets and content via HTTP. MySQL is the database that stores all your information in an easily queried format. PHP is the programming language that works with apache to help create dynamic web content.

Install apache on centOS 8; Through this tutorial, we will learn how to install and configure apache on centOS 8.

How to Install Apache on CentOS 8

Just follow the following steps to install apache on CentOS 8:

  • Step 1 – Update System Software Repository
  • Step 2 – Install Apache
  • Step 3 – Start and Manage Apache Web Server
  • Step 4 – Adjusting the Firewall
  • Step 5 – Managing Apache

Step 1 – Update System Software Repository

First of all, open terminal and command line and execute the following command into it to update system software repository:

sudo yum update

Step 2 – Install Apache

Once the system packages has been updated, then execute the following command on command line or terminal to install apache:

sudo yum install httpd

Step 3 – Start and Manage Apache Web Server

Once the installation is complete, execute the following command on command line or terminal to enable and start the Apache service:

sudo systemctl enable httpd
sudo systemctl start httpd

Then execute the following command on terminal or command line to verify apache services:

sudo systemctl status httpd

Step 4 – Adjusting the Firewall

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

Execute 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

Step 5 – Managing Apache

Let’s see Apache configuration files are structured and the best practices for managing the Apache webserver.

  • 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.
  • You can set your domain document root directory to any location you want. The most common locations for webroot include:
    • /home/<user_name>/<site_name>
    • /var/www/<site_name>
    • /var/www/html/<site_name>
    • /opt/<site_name>


Through this tutorial, we have learned how to install and configure apache on centOS 8.

Recommended CentOS Tutorials


Greetings, I'm Devendra Dode, a full-stack developer, entrepreneur, and the proud owner of My passion lies in crafting informative tutorials and offering valuable tips to assist fellow developers on their coding journey. Within my content, I cover a spectrum of technologies, including PHP, Python, JavaScript, jQuery, Laravel, Livewire, CodeIgniter, Node.js, Express.js, Vue.js, Angular.js, React.js, MySQL, MongoDB, REST APIs, Windows, XAMPP, Linux, Ubuntu, Amazon AWS, Composer, SEO, WordPress, SSL, and Bootstrap. Whether you're starting out or looking for advanced examples, I provide step-by-step guides and practical demonstrations to make your learning experience seamless. Let's explore the diverse realms of coding together.

Leave a Reply

Your email address will not be published. Required fields are marked *