Chapter 21: Managing Apache HTTP Services
Sommaire
Configuring a Basic Apache Server
Understanding Apache Configuration Files
Creating Apache Virtual Hosts
Configuring a Basic Apache Server
CONFIGURING A BASIC APACHE SERVER
Configuring a basic Apache server is not hard to do. It consists of a few easy steps:
- Step 1. Install the required software.
- Step 2. Identify the main configuration file.
- Step 3. Create some web server content.
Installing the Required Software
The Apache server is provided through some different software packages. The basic package is httpd; this package contains everything that is needed for an operational but basic web server. There are some additional packages, as well. For a complete overview, you can use the
[root@lab ~]# yum search http command, and you can use
[root@lab ~]# yum module install httpd to install the base package and common additional modules.
Identifying the Main Configuration File
The configuration of the Apache web server goes through different configuration files. The section “Understanding Apache Configuration Files” later in this chapter provides an overview of the way these files are organized. The main Apache configuration file is
/etc/httpd/conf/httpd.conf. In this section, many parameters are specified. The most important parameter to understand for setting up a basic web server is the DocumentRoot parameter. This parameter specifies the default location where the Apache web server looks for its contents.
Another important configuration parameter is the ServerRoot. This defines the default directory where Apache will look for its configuration files. By default, the /etc/httpd directory is used for this purpose, but alternative directories can be used as well. Many other configuration files are referenced in the httpd.conf file, a portion of which is shown in Example 21-1. The use of additional configuration files makes it easy for applications to install snap-in files that will be included by the Apache server from RPM packages. The names of all these configuration files are relative to the ServerRoot /etc/httpd.
Creating Web Server Content
After identifying the web server DocumentRoot, you know all you need to know to configure a basic web server. The Apache web server by default looks for a file with the name index.html and will present the contents of that document to clients using a browser to access the web server. It suffices to configure this file with very basic contents; just a line like “Welcome to my web server” will do.
To test the web server, you can launch a browser. The Firefox browser is installed by default on all graphical installations of RHEL 8. If your server does not run a graphical interface, use yum install curl to work with Apache from the command line.
Understanding Apache Configuration Files
Creating Apache Virtual Hosts