Install Apache on CentOS 8


❗️

DISCLAIMER: CentOS 8 reached End of Life (EOL) on December 31, 2021; all official repositories are inactive, no security updates or patches are available, the CentOS Project has shifted focus to CentOS Stream (a rolling-release upstream for RHEL), continued use poses significant security risks including unpatched vulnerabilities (CVEs), compliance violations, and lack of vendor support; migration paths include Rocky Linux, AlmaLinux (community-driven RHEL clones maintaining binary compatibility), Oracle Linux, or CentOS Stream 8/9; users maintaining CentOS 8 systems must implement compensating controls, use vault.centos.org for archived packages (not recommended for production), conduct thorough security assessments, and plan immediate migration to a supported distribution to maintain system integrity, security posture, and regulatory compliance.


The Apache® HTTP Server, colloquially called Apache, is a free and open-source cross-platform web server software.
Apache is an extremely popular web service that operates a large portion of the websites on the internet. This article
describes how to install Apache and open your server’s firewall to allow web traffic through.

Prerequisites

You need a Linux®-based server running CentOS® 8.

Install Apache

Perform the following steps to install Apache:

  • Run the following command to install the Apache web service, which serves as a base for your application:
$ sudo dnf -y install @httpd
  • Run the following commands to configure Apache to start on boot and update the software firewall:
$ sudo systemctl enable --now httpd  
$ sudo firewall-cmd --add-service=\{http,https} --permanent  
$ sudo firewall-cmd --reload

You should now be able to navigate to your server's IP address in a browser and see the Apache test page to
confirm you’ve configured the server correctly. This page also displays useful information to configure Apache to
serve your custom website or application.