Apache Web Server

Installing an Apache Web Server

The Apache Web Server is one of the most used web servers on the World Wide Web. Apache is responsible for serving many of the pages you view on the internet. Apache is also used as a local web server on Linux distributions. Many software packages rely on a web server to provide their configuration/administration interfaces. phpMyAdmin and Nagios Monitoring tool both require the Apache Web Server to be installed. Quite often the Apache Web Server will be automatically installed with applications like Nagios and phpMyAdmin. However, it is quite easy to install the web server directly from your Linux distributions repositories if it is not already installed. In the following example we are going to use a CentOS server.

RHEL/CentOS Installation

To install an Apache web server, issue the following command on your server: "dnf install httpd"

# dnf install httpd
Last metadata expiration check: 0:41:57 ago on Sun 30 May 2021 12:30:20 BST.
Dependencies resolved.
 Package                 Arch        Version                                      Repository      Size
 httpd                   x86_64      2.4.37-30.module_el8.3.0+561+97fdbbcc        appstream      1.7 M
Installing dependencies:
 apr                     x86_64      1.6.3-11.el8                                 appstream      125 k
 apr-util                x86_64      1.6.1-6.el8                                  appstream      105 k
 centos-logos-httpd      noarch      80.5-2.el8                                   baseos          24 k
 httpd-filesystem        noarch      2.4.37-30.module_el8.3.0+561+97fdbbcc        appstream       37 k
 httpd-tools             x86_64      2.4.37-30.module_el8.3.0+561+97fdbbcc        appstream      104 k
 mod_http2               x86_64      1.15.7-2.module_el8.3.0+477+498bb568         appstream      154 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.0 M
Is this ok [y/N]: y
Downloading Packages:
(1/9): apr-util-bdb-1.6.1-6.el8.x86_64.rpm                             196 kB/s |  25 kB     00:00    
(2/9): apr-util-openssl-1.6.1-6.el8.x86_64.rpm                         673 kB/s |  27 kB     00:00    
(3/9): apr-1.6.3-11.el8.x86_64.rpm                                     624 kB/s | 125 kB     00:00    
(4/9): apr-util-1.6.1-6.el8.x86_64.rpm                                 528 kB/s | 105 kB     00:00    
(5/9): httpd-filesystem-2.4.37-30.module_el8.3.0+561+97fdbbcc.noarch.r 751 kB/s |  37 kB     00:00    
(6/9): httpd-tools-2.4.37-30.module_el8.3.0+561+97fdbbcc.x86_64.rpm    1.3 MB/s | 104 kB     00:00    
(7/9): mod_http2-1.15.7-2.module_el8.3.0+477+498bb568.x86_64.rpm       944 kB/s | 154 kB     00:00    
(8/9): centos-logos-httpd-80.5-2.el8.noarch.rpm                        177 kB/s |  24 kB     00:00    
(9/9): httpd-2.4.37-30.module_el8.3.0+561+97fdbbcc.x86_64.rpm          3.3 MB/s | 1.7 MB     00:00    
Total                                                                  1.7 MB/s | 2.3 MB     00:01     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                               1/1 
  Installing       : apr-1.6.3-11.el8.x86_64                                                       1/9 
  Running scriptlet: apr-1.6.3-11.el8.x86_64                                                       1/9 
  Installing       : apr-util-bdb-1.6.1-6.el8.x86_64                                               2/9 
  Installing       : apr-util-openssl-1.6.1-6.el8.x86_64                                           3/9 
  Installing       : apr-util-1.6.1-6.el8.x86_64                                                   4/9 
  Running scriptlet: apr-util-1.6.1-6.el8.x86_64                                                   4/9 
  Installing       : httpd-tools-2.4.37-30.module_el8.3.0+561+97fdbbcc.x86_64                      5/9 
  Installing       : centos-logos-httpd-80.5-2.el8.noarch                                          6/9 
  Running scriptlet: httpd-filesystem-2.4.37-30.module_el8.3.0+561+97fdbbcc.noarch                 7/9 
  Installing       : httpd-filesystem-2.4.37-30.module_el8.3.0+561+97fdbbcc.noarch                 7/9 
  Installing       : mod_http2-1.15.7-2.module_el8.3.0+477+498bb568.x86_64                         8/9 
  Installing       : httpd-2.4.37-30.module_el8.3.0+561+97fdbbcc.x86_64                            9/9 
  Running scriptlet: httpd-2.4.37-30.module_el8.3.0+561+97fdbbcc.x86_64                            9/9 
  Verifying        : apr-1.6.3-11.el8.x86_64                                                       1/9 
  Verifying        : apr-util-1.6.1-6.el8.x86_64                                                   2/9 
  Verifying        : apr-util-bdb-1.6.1-6.el8.x86_64                                               3/9 
  Verifying        : apr-util-openssl-1.6.1-6.el8.x86_64                                           4/9 
  Verifying        : httpd-2.4.37-30.module_el8.3.0+561+97fdbbcc.x86_64                            5/9 
  Verifying        : httpd-filesystem-2.4.37-30.module_el8.3.0+561+97fdbbcc.noarch                 6/9 
  Verifying        : httpd-tools-2.4.37-30.module_el8.3.0+561+97fdbbcc.x86_64                      7/9 
  Verifying        : mod_http2-1.15.7-2.module_el8.3.0+477+498bb568.x86_64                         8/9 
  Verifying        : centos-logos-httpd-80.5-2.el8.noarch                                          9/9 



The Apache Web server is known on RHEL based systems as "httpd".

To make sure the Web Server is started automatically at system boot time, you must issue the following command:

systemctl enable httpd

# systemctl enable httpd
Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service → /usr/lib/systemd/system/httpd.service.

# systemctl is-enabled httpd

To start the Web Server, you will need to issue the following command:

systemctl start httpd

# systemctl start httpd

# systemctl status httpd
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
   Active: active (running) since Sun 2021-05-30 13:17:59 BST; 9s ago
     Docs: man:httpd.service(8)
 Main PID: 2284 (httpd)
   Status: "Running, listening on: port 80"
    Tasks: 213 (limit: 9206)
   Memory: 29.1M
   CGroup: /system.slice/httpd.service
           ├─2284 /usr/sbin/httpd -DFOREGROUND
           ├─2285 /usr/sbin/httpd -DFOREGROUND
           ├─2286 /usr/sbin/httpd -DFOREGROUND
           ├─2287 /usr/sbin/httpd -DFOREGROUND
           └─2315 /usr/sbin/httpd -DFOREGROUND

May 30 13:17:59 client01a systemd[1]: Starting The Apache HTTP Server...
May 30 13:17:59 client01a httpd[2284]: AH00558: httpd: Could not reliably determine the server's fully>
May 30 13:17:59 client01a systemd[1]: Started The Apache HTTP Server.
May 30 13:17:59 client01a httpd[2284]: Server configured, listening on: port 80

From the above we can see that the "httpd" service has been started. The status was displayed by issuing the following status command:

systemctl status httpd

As a test, you can point your browser to the IP address of your web server. In this example, our IP address is

Linux Apache Web Server

Configuration Files

The main configuration files can be found under the following location: /etc/httpd/conf/httpd.conf The main document area is located in the following path: /var/www/html

# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
DocumentRoot "/var/www/html"

If you wish to test this location, then you can create a simple "index.html" file and place this in the above location.

Test index.html:

<meta content="text/html; charset=ISO-8859-1" http-equiv="content-type">
<title>www.landoflinux.com Test Page</title>
<big><big><big>Welcome to my test index.html page</span></big></big></big><br>

The output from the above html would give us a simple page of:

Linux Apache Web Server Demo Page

Further Reading

For more information on the configuration of the Apache Web Server, visit the Apache homepage: Apache Website