The Apache HTTP Server, commonly referred to as Apache, is one of the most widely used web servers around the world. It provides many powerful features, including dynamically loadable modules, robust media support, and extensive integration with other popular software. On distributions like CentOS, Red Hat, and Fedora, Apache is an essential component that can be easily installed and configured.

The Apache HTTP Server, commonly referred to as Apache, is one of the most widely used web servers around the world. It provides many powerful features, including dynamically loadable modules, robust media support, and extensive integration with other popular software. On distributions like CentOS, Red Hat, and Fedora, Apache is an essential component that can be easily installed and configured.

CentOS, Red Hat, and Fedora are among the most popular distributions for enterprise solutions. They provide a stable environment for hosting, and Apache is fully supported on these platforms. This guide will help you install and configure Apache on these distributions.

Steps to install and configure Apache on CentOS, Red Hat or Fedora:

  1. Launch terminal.
  2. Install Apache package using dnf.

    $ sudo dnf install --assumeyes httpd
    [sudo] password for user: 
    Updating Subscription Management repositories.
    Unable to read consumer identity
    
    This system is not registered with an entitlement server. You can use subscription-manager to register.
    
    CentOS Stream 9 - BaseOS                        483 kB/s | 8.6 MB     00:18    
    CentOS Stream 9 - AppStream                     886 kB/s |  16 MB     00:18    
    CentOS Stream 9 - Extras packages               862  B/s |  14 kB     00:16    
    Dependencies resolved.
    ================================================================================
     Package                 Architecture Version              Repository      Size
    ================================================================================
    Installing:
     httpd                   aarch64      2.4.57-5.el9         appstream       47 k
    Installing dependencies:
     apr                     aarch64      1.7.0-11.el9         appstream      121 k
     apr-util                aarch64      1.6.1-23.el9         appstream       96 k
     apr-util-bdb            aarch64      1.6.1-23.el9         appstream       13 k
     centos-logos-httpd      noarch       90.4-1.el9           appstream      252 k
     httpd-core              aarch64      2.4.57-5.el9         appstream      1.3 M
     httpd-filesystem        noarch       2.4.57-5.el9         appstream       14 k
     httpd-tools             aarch64      2.4.57-5.el9         appstream       80 k
    Installing weak dependencies:
     apr-util-openssl        aarch64      1.6.1-23.el9         appstream       15 k
     mod_http2               aarch64      1.15.19-5.el9        appstream      145 k
     mod_lua                 aarch64      2.4.57-5.el9         appstream       59 k
    
    Transaction Summary
    ================================================================================
    Install  11 Packages
    
    Total download size: 2.2 M
    Installed size: 11 M
  3. Configure Apache options as necessary.

    $ sudo vi /etc/httpd/conf/httpd.conf
  4. Test Apache configuration for errors.

    $ sudo apachectl configtest
    AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using fe80::e5f:4565:1b9c:6e87. Set the 'ServerName' directive globally to suppress this message
    Syntax OK
  5. Restart httpd service once Apache configuration contains no error.

    $ sudo systemctl restart httpd
  6. Configure httpd service to start on boot.

    $ sudo systemctl enable httpd
    Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service → /usr/lib/systemd/system/httpd.service.
  7. Allow HTTP and HTTPS traffic in the firewall if enabled.

    $ sudo firewall-cmd --permanent --add-service=http --add-service=https
    success
  8. Reload firewall for the added rules to be enabled.

    $ sudo firewall-cmd --reload
    success
  9. Access the website using browser or command line tools to test if your Apache web server is up and running.

    $ curl 127.0.0.1
    <!DOCTYPE html>
    <html lang="en">
    <head>
      <meta name="generator" content="HTML Tidy for HTML5 for Linux version 5.7.28">
      <title>HTTP Server Test Page powered by CentOS</title>
      <meta charset="utf-8">
      <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
      <link rel="shortcut icon" href="http://www.centos.org/favicon.ico">
    ##### snipped