19

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?

chrtp
  • 193

3 Answers3

19

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.

suspectus
  • 5,008
2

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.

Satanicpuppy
  • 7,205
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
    ServerName bayxxx.com
    ServerAlias www.bayxxx.com
    <Directory "/www/bayxxx.com/www/root">
        allow from all
        Options +Indexes
    </Directory>
</VirtualHost>
bone
  • 15
Pavel
  • 111