Red Hat is a prevalent choice of Linux distribution for server deployment, and Apache is one of the most popular web server software. This makes Red Hat and Apache the more popular web server deployment combinations.

CentOS is a free replacement for Red Hat Enterprise Linux, and Fedora is geared more towards the end-user. Both Red Hat variants fully support Apache and can be installed from the command line using yum or dnf.

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

  1. Launch terminal application.
  2. Install httpd package using yum.
    $ sudo yum install --assumeyes httpd
    [sudo] password for user:
    Last metadata expiration check: 0:04:30 ago on Mon 17 Feb 2020 05:37:42 PM EST.
    Dependencies resolved.
     Package                 Arch        Version                                    Repository      Size
     httpd                   x86_64      2.4.37-16.module_el8.1.0+256+ae790463      AppStream      1.7 M
    Installing dependencies:
     apr                     x86_64      1.6.3-9.el8                                AppStream      125 k
     apr-util                x86_64      1.6.1-6.el8                                AppStream      105 k
     centos-logos-httpd      noarch      80.5-2.el8                                 AppStream       24 k
     httpd-filesystem        noarch      2.4.37-16.module_el8.1.0+256+ae790463      AppStream       35 k
     httpd-tools             x86_64      2.4.37-16.module_el8.1.0+256+ae790463      AppStream      103 k
     mod_http2               x86_64      1.11.3-3.module_el8.1.0+213+acce2796       AppStream      158 k
    Installing weak dependencies:
     apr-util-bdb            x86_64      1.6.1-6.el8                                AppStream       25 k
     apr-util-openssl        x86_64      1.6.1-6.el8                                AppStream       27 k
    Enabling module streams:
     httpd                               2.4
    Transaction Summary
    Install  9 Packages
    Total download size: 2.3 M
    Installed size: 6.6 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 automatically start during system boot.
    $ sudo systemctl enable httpd
    Created symlink /etc/systemd/system/ → /usr/lib/systemd/system/httpd.service.
  7. Add http and/or https services to the firewall.
    $ sudo firewall-cmd --permanent --add-service=http --add-service=https
  8. Reload firewall for the added rules to be enabled.
    $ sudo firewall-cmd --reload
  9. Access the website using browser or command line tools to test if your Apache web server is up and running.
    $ curl
    <?xml version="1.0" encoding="utf-8"?>
    <html lang="en">
        <title>CentOS 提供的 Apache HTTP 服务器测试页</title>
        <meta charset="utf-8"/>
        <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"/>
        <link rel="shortcut icon" href=""/>
        <link rel="stylesheet" media="all" href="noindex/common/css/bootstrap.min.css"/>
        <link rel="stylesheet" media="all" href="noindex/common/css/styles.css"/>
    ##### snipped
Discuss the article:

Comment anonymously. Login not required.