In what order does Apache load conf files and which ones?
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.
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.
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>