05 - Apache Web Server

Web Servers

Web Servers are software that accept requests via HTTP (Hyper Text Transfer Protocol). HTTP was created to distribute web content such as human-readable pages (called documents). The standard format for these documents is html, however, other digital formats such as images, video and audio can be presented. Non-visual files can also be hosted and distributed on web servers, such as binary files for distributing software, as well as scripts and web applications that run on the client agent, such as the Web Apps, web-based games, and advertising and user tracking "analytics" tools.

The primary client agents for viewing web content are web browsers, such as Chrome, Firefox, and Safari. Web browsers display web documents and execute web applications and scripts for a human end user. However, other agents, such as web crawlers, may also visit a public site.

Web servers are not just used to host web content and documents on the internet. Many network devices, such as embedded sensors, management computers, printers, switches, routers and many IoT systems use web servers to provide management, monitoring, and configuration interfaces. These devices may provide a web user interface that can be used by human users, but for large-scale deployments, they also expose an API to other software and machines. Federated enterprise application and infrastructure management, API calls are used to monitor, configure and manage systems. REST API and SOAP are examples of application interfaces that operate using the HTTP protocol. HPE iLO and Dell iDRAC are examples of embedded software that use web servers to this end. Many cloud services, such as AWS and Azure, also expose a REST API for this purpose.

The following is a screenshot of a web user interface of the embedded management computer on a Dell PowerEdge server (iDRAC):
590028e574d6834247a3c027f655f7db.png

Web Server Common Features

source: https://en.wikipedia.org/wiki/Web_server

These are basic features that most web servers usually have:

A few other more advanced and popular features (only a very short selection) are the following ones.

There are many Web Server software for various purposes, ranging from management interfaces for network appliances and embedded (such as routers, switches, storage devices, printers, IoT) to full-fledged global websites and applications. Here are examples of some popular web servers for internet server applications:

Web Server Type Use Cases Key Features Performance
Apache Web Server Open Source Hosting static and dynamic content, General Purpose Wide module support (extensible), robust community high performance, highly configurable
Apache Tomcat Open Source Java applications Serves Java Servlets and JSPs Moderate, but can handle heavy loads with proper tuning
Nginx Open Source Serving high-traffic websites, load balancing Reverse proxy, event-driven architecture high performance, highly configurable
Microsoft IIS Proprietary Windows Server ONLY Integrated with Windows Server, GUI management Moderate to high, optimized for Windows
LiteSpeed Proprietary High-performance/Enterprise applications HTTP/3 support, Advanced caching features Very high, especially with advanced caching
OpenLiteSpeed Open Source simpler setups than LiteSpeed, smaller applications Async I/O, basic caching features Very high, especially for PHP applications
Caddy Open Source Quick deployments, automatic HTTPS Easy configuration, automatic TLS High, user-friendly setup

Apache Web Server

Apache Software Foundation (ASF)

See: https://en.wikipedia.org/wiki/The_Apache_Software_Foundation
ASF is an American non-profit corporation that supports a number of open-source software projects and is the author of the Apache License. ASF has a meritocracy governance model, where membership is granted to volunteers who have made the most contributions to a project. ASF top-level projects are semi-autonomous; however, ASF retains the appropriate intellectual property rights through the Apache license to have the means "to provide legal protection to volunteers working on Apache projects, and to prevent the Apache brand name from being used by other organizations without permission".

The Apache license is a permissive license. It allows users to use the software for any purpose, to distribute it, to modify it, and to distribute modified versions of the software under the terms of the license, without concern for royalties. This license is also used by many non-ASF open-source projects. (see: https://en.wikipedia.org/wiki/Apache_License).

Apache2

The current version of Apache HTTP Server is a cross-platform open source software released under the Apache 2.0 license. It is an integral part of the web as LAMP (Linux, Apache, MySQL, PHP) is a popular active application back-end for many web-based applications and sites.

The Apache HTTP server has a modular design, meaning any feature can be easily added. Modules can support new protocols, programming languages, scripts, and connections to other services and applications, such as databases. Additionally, Apache2 comes with many included modules that can be easily enabled to add encryption, virtual hosts, application firewalls, and many other functions as needed.

The Apache2 virtual host module is especially useful as it allows many websites or web applications to be hosted at the same IP address. The server can identify which site to serve to the visitor based on a destination other than the IP address, such as hostname, FQDN, Domain, or URL, which would be in the HTTP headers.

Document Store

The location where a site's assets are stored is called "Document Store". The root of the document store is generally presented to the site clients (visitors), and the displayed URL is relative to the Document Store root. The default location is a directory under /var/www; however, you can specify and change this path in the host configuration. Virtual hosts can have different locations for each site, or even relative paths specified. For example, if enabling a host for each user, a document store can be specified under each user's directory.

You must make sure that you have set the correct permissions for all files and directories, as this directory will be exposed to the network and the internet. The default permissions for static files (such as .html, images, CSS, and other files) are 644 (-rw-r--r--), and for dynamic files and scripts that get executed on the server are 755 (-rwxr-xr-x).

Apache2 Installation and Configuration

Installation in Ubuntu is fairly straightforward, as Apache2 is already included in the repositories:
sudo apt install apache2

The configuration directory:
/etc/apache2

Configuration files

There are two types of configuration directories:

CLI Utilities

To check the status of the service from the OS, use the systemctl or service. For example:

Apache2 comes with a utility for managing the service gracefully: apachectl:

Interesting Files, Utilities, and Commands