8

I'm looking at a CentOS 6.5 server with a webframework installed that has been added to over the years by many. There are what looks like 5 active .conf files in /conf, including httpd.conf.

In httpd.conf the include reads

Include conf.d/*.conf

and that grabs all the files in that directory, but without any specific order applied that I'm aware of, and so what about the /conf (no .d) directory?

Is there a setting that states the load order or are they just taken from a-z?

I'm not the server admin, I'm a developer and the problem lies in the paths for uploading files to a /Temp dir, where I have checked that the path specified is correct for the files I myself am concerned with.

So, the 1st question is:

Does Apache load everything from /conf or is there a list specified somewhere?

The 2nd question would be:

In what order does Apache load the files, alphabetically?

Lastly:

Does a file that does not end in .conf get included? For example if I name something myconfig.conf.old will Apache skip it?

12

The order is alphabetical. It only loads what the Include path specifies. In the case of Include conf.d/*.conf apache will load all files with names ending in .conf.

This is an extract from Apache Documentation :

Shell-style (fnmatch()) wildcard characters can be used to include several files at once, in alphabetical order. In addition, if Include points to a directory, rather than a file, Apache will read all files in that directory and any subdirectory. But including entire directories is not recommended, because it is easy to accidentally leave temporary files in a directory that can cause httpd to fail.

  • Thank you, that answers questions 1 & 2 certainly. I looked though the Apache docs but couldn't find the answer. – chrtp Jan 22 '14 at 13:22
  • Broadly (order of config items overrides earlier items) that is correct. Certainly if the commands are in the same configuration section. But for example it is possible (using AllowOverride) to override config items with config in an .htaccess file. – suspectus Jan 22 '14 at 13:31
  • Sorry, I edited my comment before I saw yours. There is no .htaccess in this case, but there is a file starting with 't' that is overriding all else. I'm going to rename or move the file. – chrtp Jan 22 '14 at 13:35
  • @chrtp, and why a file starting with t would override all else? – Andrew Savinykh Feb 13 '17 at 13:17
1

Apache loads extra configuration based on the "Include" directive. It probably looks like this:

Include conf.d/*.conf

So, obviously, it includes everything in "conf.d" that looks like "*.conf".

To make it even more insane, you can add an arbitrary number of directories with "include" all of which could contain roughly the same config files, that all would happily override each other at start up...And then themselves be over-ridden by the .htaccess file in various hosted directories.

As near as I can tell, httpd.conf is first, followed by the directories in the order in which they are included and then alphabetically from there.

Good times. You can use apachectl -t or apachectl configtest to get some idea of whether or not your configuration is going to cause trouble.

  • 1
    Thank you, it looks like someone has left a file called template.conf in there that of course loads last and then overrides any other files that specify the path to /Temp. I can only guess as to what else is being broken with that there! – chrtp Jan 22 '14 at 13:29
  • 1
    @chrtp To add to the hilarity, directives can be specified at runtime using -C (for adding them before reading config files) and -c (for reading them after config files), so you could source an entire different config from the command line on startup. – Satanicpuppy Jan 22 '14 at 13:47
1

I you want to change the order just open the first conf file in directory sites-available and before first VirtualHost *:80 add your virtual host code.

In my case I want hub.xxx.com.conf to be before bayxxx.com.conf. So I open hub.xxx.com.conf and place virtual host at the beginning of a file

For example:

<VirtualHost *:80>

DocumentRoot /www/hub.xxx.com/www/root
ServerName hub.xxx.com
ServerAlias *.hub.xxx.com
<Directory "/www/hub.xxx.com/www/root">
    allow from all
    Options +Indexes
</Directory></VirtualHost><VirtualHost *:80>

DocumentRoot /www/bayxxx.com/www/root

<Directory "/www/bayxxx.com/www/root">
    allow from all
    Options +Indexes
</Directory>

ServerName bayxxx.com
ServerAlias www.bayxxx.com
</VirtualHost>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.