Apache Webserver Install on Linux

This document describe the process of installing Apache on RHEL.

  1. Install Apache and Apache related tools:

    sudo dnf install httpd httpd-tools
  2. Check the version of Apache:

    httpd -v
  3. Start Apache:

    sudo systemctl start httpd
  4. Enable Apache to start at boot:

    sudo systemctl enable httpd
  5. Allow Apache to Make Outgoing Network Connections:

    By default, SELinux forbids Apache to make outgoing network connections.

    If Apache needs to make requests to an outside network service, then run the following command to allow this action.

    setsebool -P httpd_can_network_connect on
  6. Check Apache status and confirm that it’s listening on port 80:

    sudo systemctl status httpd
  7. Set the apache user as the owner of the web directory:

    sudo chown apache:apache /var/www/html -R
  8. Configure firewall to allow traffic to ports: 80 and 443:

    sudo firewall-cmd --permanent --zone=public --add-service=http  (1)
    
    sudo firewall-cmd --permanent --zone=public --add-service=https (2)
    
    sudo systemctl reload firewalld (3)
    1 Open port 80
    2 Open port 443
    3 Restart the FW daemon
  9. Confirm Apache accessibility:

    1. First create a test page:

      sudu vi /var/www/html/index.html
    2. Enter the following html into that file:

      <h1 align="middle">Welcome - this is a test page!</h1>
    3. Launch your browser and browse to the Linux server’s DNS name:

      Apache-URL

    4. You should see the test page:

      Apache-Welcome

  10. Apache is now installed.