0

Is there a widely adopted convention for naming apache configuration files?

I'm working on an Ubuntu machine and the example files is named 000-default. I recall at a previous project the sysadmin seemed to have an obscure way of choosing the 3-digit prefix to the file names.

I'm curious how most people do this?

Also, does it actually matter all that much? I guess the files are imported in ascending order.

3

The files are indeed imported in lexicographical order. How you achieve this ordering is entirely at your discretion, but the easiest method is by prefixing file names with digits/numbers. I'm not aware of any preferred/standardised style for doing this, and what you have described (3 digit prefixes) is a good a method as any. It's fixed length, which also aids visually on a terminal. If you have less than 1000 conf files, 3 digits would make sense. But if you only have up to 100, maybe 2 digits would be better, up to 10 files, single digit, etc etc.

It is also possible to group Apache conf files into sub-directories. Simply create folders like 0.conf, 1.conf, and then place conf files in those to achieve ordering on a more grouped basis. Directories must be named *.conf to be included. This may be useful if you need to disable an entire group of websites in one go, by simply renaming the directory (mv name.conf name.off) and reloading Apache. All conf files under that directory will now have been removed from the configuration.

Note that it does depend on the application as to whether sub-directories are recursively supported. I tried this trick with dnsmasq recently and it doesn't work. Nginx also doesn't support recursively traversing *.conf directories (tested against version 1.10.2).

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.