Gentoo uses a different configuration layout for Apache than other systems. It also provides some great tools for editing your configuration.
In this article we’ll get an overview of how Gentoo organises Apache’s configuration files; this will help later with knowing where to look when we want to change certain settings.
On a Gentoo Slice, Apache keeps it’s configuration files in ‘/etc/apache2’. Let’s move into the config folder and have a look:
cd /etc/apache2 ls
You will see something like this:
Lets take a closer look at these files and directories. The directories are shown above in blue.
This file helps Apache choose the correct MIME content type when serving static files. It decides a file’s content type, not only from the file extension but from the first few bytes of the file’s content — known as it’s magic number.
For example, thanks to this file, you could have a JPEG image named ‘image.gif’ and Apache would still know that it’s a JPEG and tell the browser accordingly, even though it is named ‘.gif’.
This directory contains the server side key and certificate files to enable it to serve SSL-encrypted pages — pages launched with a URL starting with “https://”.
By default it contains a test certificate that will raise warning messages in practically all browsers. Once you have purchased your own SSL certificate, you’ll be able to put the files for that in this directory.
This is the main Apache configuration file, it is the glue that holds the entire Apache configuration together. We’ll look at the contents of this in our next article.
When Apache loads, it reads this file, which in turn tells Apache to read other config files. For example it will load all files in ‘/etc/apache/vhosts.d’ that end in ‘.conf’, the same goes for the other directory ‘modules.d’.
Inside this directory you’ll store the configuration files for each site you want to serve - these are known as vhosts or virtual hosts.
Have a look now and you’ll see three files:
demo@gentootest ~ $ ls /etc/apache2/vhosts.d/ 00_default_ssl_vhost.conf 00_default_vhost.conf default_vhost.include
These files are used to define the default site (virtual host). One file is for the ‘ssl’ (‘https://’) version, and there’s one for the standard (‘http://’) version of the site.
The ‘default_vhost.include’ file contains configuration information common to both ‘.conf’ files, and is included by them.
Remember all files ending in ‘.conf’ are automatically imported by ‘http.conf’.
This directory mainly contains configuration files for various Apache modules; everything in this directory ending in ‘.conf’ will be imported by ‘httpd.conf’.
Lets take a look at some of these files:
demo@gentootest /etc/apache2 $ ls /etc/apache2/modules.d/ 00_default_settings.conf 00_mod_autoindex.conf 00_mod_mime.conf 00_mpm.conf 45_mod_dav.conf 00_error_documents.conf 00_mod_info.conf 00_mod_status.conf 10_mod_mem_cache.conf 46_mod_ldap.conf 00_languages.conf 00_mod_log_config.conf 00_mod_userdir.conf 40_mod_ssl.conf 70_mod_php5.conf
Files will be loaded in the order that they are named and numbered, so the files starting with ‘00_’ will be loaded first.
Files with ‘_mod_’ in their name are aimed at specific modules. The other files contain general Apache configuration settings that don’t belong in ‘httpd.conf’, nor are specific to any one module. Let’s take a look at those now.
The ‘00_default_settings.conf’ file contains a lot of configuration settings that would normally be found in ‘httpd.conf’ in other Linux flavours, such as ‘timeout’ values.
The ‘00_languages.conf’ file allows you to specify the default language of your content and how Apache should choose the best content when the browser asks for content in different languages.
The ‘00_error_documents.conf’ file defines how error messages are displayed. For example when Apache can’t find a page, it will show a ‘404 - File not found’ error by default. With this config file, you can make that look nicer and display different error messages.
Detailing the other module-related files is beyond the scope of this article.
The last config file we’ll look at is in a totally different directory, Gentoo’s ‘/etc/conf.d’ directory.
Most daemon (server) programs that you install on Gentoo will have a file in that directory.
For Apache this file is mainly used to decide what modules Apache should load on start-up. There are some other advanced settings in here, but they’re really best left alone 99% of the time.
This is where the actual html content is kept for Apache’s default virtual host. However, as explained in the upcoming articles, we’ll be keeping content for our virtual hosts in a different style of directory structure; this is to keep things consistent with the other Slicehost articles for Apache.
This article is designed to give you an overview of how Apache’s configuration files are organized on a Gentoo slice. In our next article, we’ll take a closer look inside some of these files.