Jump to content

Apache HTTP Server

From MukeWiki

Apache HTTP Server

Apache HTTP Server in Fedora/RHEL provided by httpd packages.

/etc/httpd/conf/httpd.conf         -rw-r--r--. (644)   root:root   # httpd.conf(5)
/etc/httpd/conf.d/autoindex.conf   -rw-r--r--. (644)   root:root
/etc/httpd/conf.d/welcome.conf     -rw-r--r--. (644)   root:root
$ httpd -h   # httpd(8)
$ httpd -V   # HTTPD_ROOT="/etc/httpd"
$ httpd -S   # ServerRoot: "/etc/httpd"

$ httpd -D DUMP_RUN_CFG       # DUMP_INCLUDES, DUMP_MODULES, DUMP_VHOSTS
$ sudo httpd -D DUMP_CONFIG   # DUMP_CONFIG requires mod_info module
$ sudo httpd -D DUMP_CONFIG  | grep -i wiki

Version of apachectl used on Fedora/RHEL is a replacement script (wrapper around systemctl and manipulates the systemd service for httpd) intended to be mostly (but not completely) compatible with version provided with Apache httpd. More info apachectl(8).

Apache HTTP Server modules

.htaccess files provide a way to make configuration changes on a per-directory basis. You should avoid using .htaccess files completely if you have access to httpd main server config file. Using .htaccess files slows down your Apache http server. Any directive that you can include in a .htaccess file is better set in a Directory block, as it will have the same effect with better performance.

The use of .htaccess files can be disabled completely by setting the AllowOverride directive to None.

AllowOverride None

Protecting System Settings security tip. Prevents the use of .htaccess files in all directories apart from those specifically enabled. Note that this setting is the default since Apache 2.3.9.

<Directory "/">
    AllowOverride None
</Directory>

The Alias directive allows documents to be stored in the local filesystem other than under the DocumentRoot.

Alias "/image" "/usr/local/pub/image"

The URL-path is case-sensitive, even on case-insensitive file systems. Note that if you include a trailing / on the URL-path then the server will require a trailing / in order to expand the alias. Likewise, if you omit the slash on the URL-path then you must also omit it from the file-path.


The Options directive controls which server features are available in a particular directory.
Normally, if multiple Options could apply to a directory, then the most specific one is used and others are ignored; the options are not merged. However if all the options on the Options directive are preceded by a + or - symbol, the options are merged (added/removed).

<Directory "/example">
    Options Indexes FollowSymLinks
</Directory>

Indexes If a URL which maps to a directory is requested and there is no DirectoryIndex (e.g., index.html) in that directory, then mod_autoindex will return a formatted listing of the directory. See also /etc/httpd/conf.d/autoindex.conf for default values.

FollowSymLinks The server will follow symbolic links in this directory. This is the default setting.


mod_authz_core provides some generic authorization providers which can be used with the Require directive. mod_authz_host provides authorizations based on host (name or IP address).

Require all granted
Require all denied
Require ip 127.0.0.1
Require host muke.saske.sk
Require local

mod_info provides a comprehensive overview of the server configuration.

<Location "/server-info">
    SetHandler server-info
    Require local
</Location>