Installing the Apache HTTP Server (httpd) on CentOS Stream or Red Hat Enterprise Linux gives the host a supported web service for static sites, internal tools, and reverse-proxy front ends. A clean first-time setup avoids the common state where the package is installed but the service is still stopped or unreachable on port 80.

On RHEL-family systems, Apache is packaged as httpd and managed through the httpd systemd unit. The main server configuration lives in /etc/httpd/conf/httpd.conf, while extra configuration is commonly loaded from /etc/httpd/conf.d/ and /etc/httpd/conf.modules.d/.

The current supported path still uses the distro package manager, the systemd service, and an explicit firewall rule for 80/tcp when firewalld is active. Content placed under /var/www/html/ inherits the correct httpd_sys_content_t SELinux context by default, but custom document roots, extra listen ports, or HTTPS need additional configuration beyond this base install.

Steps to install Apache on CentOS or RHEL:

  1. Open a terminal session with an account that can use sudo.
  2. Install the Apache package from the current system repositories.
    $ sudo dnf install --assumeyes httpd
    Dependencies resolved.
    ##### snipped #####
    Installed:
      httpd-2.4.62-13.el9
    Complete!

    On older CentOS or RHEL releases that still use yum, replace dnf with yum.

  3. Optionally set a global ServerName in the main Apache configuration file before the first start.
    $ sudo vi /etc/httpd/conf/httpd.conf

    Adding a line such as ServerName www.example.com suppresses the common fully-qualified domain name warning during syntax tests and service startup.

  4. Test the Apache configuration before starting the service.
    $ sudo apachectl configtest
    AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 192.0.2.10. Set the 'ServerName' directive globally to suppress this message
    Syntax OK

    The AH00558 message is a warning, not a syntax failure. apachectl configtest is equivalent to apachectl -t.

  5. If firewalld manages the host firewall, open HTTP traffic and reload the rules.
    $ sudo firewall-cmd --permanent --add-port=80/tcp
    success
    $ sudo firewall-cmd --reload
    success

    Open 443/tcp later after TLS is configured. If the host uses a different firewall stack, apply the equivalent rule there instead.

  6. Enable and start the httpd service.
    $ sudo systemctl enable --now httpd
    Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service → /usr/lib/systemd/system/httpd.service.

    systemctl enable --now httpd starts Apache immediately and also enables it at boot.

  7. Confirm that the httpd service is running.
    $ sudo systemctl is-active httpd
    active

    If this command does not return active, inspect sudo journalctl --unit=httpd --no-pager --lines=20 before retrying the start.

  8. Create a simple test page in the default document root.
    $ printf '<h1>Apache is working on CentOS or RHEL</h1>\n' | sudo tee /var/www/html/index.html >/dev/null

    Files under /var/www/html/ receive the correct httpd_sys_content_t SELinux label by default. If you serve content from another path, label that path before expecting Apache to read it.

  9. Request the local site to verify that Apache answers on port 80.
    $ curl -I http://127.0.0.1/
    HTTP/1.1 200 OK
    Date: Thu, 09 Apr 2026 04:47:17 GMT
    Server: Apache/2.4.62 (CentOS Stream)
    Last-Modified: Thu, 09 Apr 2026 04:47:15 GMT
    ##### snipped #####
    Content-Type: text/html; charset=UTF-8

    On RHEL, an empty /var/www/html/ directory shows the default test page instead of your own content. Creating index.html first makes the verification result predictable.

    Use http://server_ip_or_host_name/ from another machine after DNS and firewall access are ready.