Skip to content

A Comprehensive Guide to Setting Up the Apache HTTP Web Server: Step-by-Step Instructions for Beginners

Estimated time to read: 2 minutes

The Apache HTTP server is the most widely-used web server in the world. It provides many powerful features including dynamically loadable modules, robust media support, and extensive integration with other popular software.

Prerequisites:

  • Red Hat Enterprise Linux 9 installed and configured.
  • Basic knowledge of the Linux command line.

Installation

  • Installing on Fedora/CentOS/Red Hat Enterprise Linux

    sudo yum install httpd 
    
  • Installing on Ubuntu/Debian

    sudo apt install apache2
    
  • If you use firewalld, open the TCP port 80 in the local firewall

    firewall-cmd --permanent --add-port=80/tcp
    firewall-cmd --reload
    
  • Enable and start the httpd service

    systemctl enable --now httpd
    

Managing the Apache httpd service

  • To start the httpd service

    systemctl start httpd
    
  • To check the httpd status

    systectl status httpd 
    
  • To stop the httpd service

    systectl stop httpd
    
  • To restart the httpd service

    systemctl restart httpd
    

Apache Httpd Webserver configuration file Structure

The httpd, by default, reads the configuration files after start. You can see the list of the locations of configuration files in the table below.

Path Description
/etc/httpd/conf/httpd.conf The main configuration file.
/etc/httpd/conf.d/ An auxiliary directory for configuration files that are included in the main configuration file.
/etc/httpd/conf.modules.d/ An auxiliary directory for configuration files which load installed dynamic modules packaged in Red Hat Enterprise Linux. In the default configuration, these configuration files are processed first.

Server Logs

In order to effectively manage a web server, it is necessary to get feedback about the activity and performance of the server as well as any problems that may be occurring. The Apache HTTP Server provides very comprehensive and flexible logging capabilities. This document describes how to configure its logging capabilities, and how to understand what the logs contain.

  • RHEL / Red Hat / CentOS / Fedora Linux Apache access file location

     /var/log/httpd/access_log