How to install Apache on RHEL 8 / CentOS 8 Linux

The Apache HTTP Server or simply Apache, is free and open-source cross-platform web server software developed and maintained by Apache Software Foundation. Apache is a easy to learn and configure web server providing an ability to host websites mainly via HTTP or HTTPS protocols. Under RHEL 8 / CentOS 8 system Apache webserver is know under name httpd.

In this tutorial you will learn:

  • How to install Apache webserver
  • How to enable and start Apache webserver
  • How to open firewall HTTP port 80
  • How to create basic same website

Installation of Apache Web Server on RHEL 8 / CentOS 8 using dnf command

Installation of Apache Web Server on RHEL 8 / CentOS 8 using dnf command

Software Requirements and Conventions Used

Software Requirements and Linux Command Line Conventions
Category Requirements, Conventions or Software Version Used
System Red Hat Enterprise Linux 8
Software Apache/2.4.35 (Red Hat Enterprise Linux)
Other Privileged access to your Linux system as root or via the sudo command.
Conventions # – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
$ – requires given linux commands to be executed as a regular non-privileged user

How to install Apache on RHEL 8 / CentOS 8 Linux step by step instructions

  1. First step is to use dnf command to install package called httpd:
    # dnf install httpd
    


  2. Run and enable the Apache webserver to start after reboot:
    # systemctl enable httpd
    # systemctl start httpd
    
  3. Optionally, if you need your Apache web server to be accessed from remote locations open HTTP firewall port 80:
    # firewall-cmd --zone=public --permanent --add-service=http
    # firewall-cmd --reload
    

    For more information visit RHEL 8 open HTTP firewall port 80 and HTTPS port 443 with firewalld tutorial.

  4. Insert your website files.

    By default the Apache web server will greet you with a default welcome page.To disable the default Apache welcome page insert your index.html into /var/www/html/ directory. For example:

    echo Apache on RHEL 8 / CentOS 8 > /var/www/html/index.html
    
  5. Access your website.

    To access your new sample website navigate your web browser to either http://YOUR-APACHE-IP-ADDRESS or http://YOUR-APACHE-HOSTNAME. For example http://192.168.1.151.