50

I am configuring apache and by default I have the directories /etc/httpd/conf and /etc/httpd/conf.d. What is the difference?

Also you can see the suffix in many other directories like /etc/init.d, /etc/cron.d, etc...

SCL
  • 895
  • 1
  • 11
  • 13
  • 1
    it means it's referring to a daemon – dynamic Feb 25 '11 at 11:37
  • dupe: http://askubuntu.com/questions/7648/many-directories-have-a-d-suffix-extension-what-does-it-mean – Sirex Feb 25 '11 at 12:03
  • 10
    @yes123: That theory doesn't fit well with `/etc/apt/sources.list.d/`, `/etc/profile.d` etc – Martin Feb 25 '11 at 12:04
  • From the answers given by Haakon and deltaray, I wonder if `.d` stands for `default`. It doesn't, according to the information here, but it seems logical. Perhaps I can go ahead and think of it that way? – Smandoli Nov 01 '12 at 19:21

2 Answers2

57

"d" stands for directory and such a directory is a collection of configuration files which are often fragments that are included in the main configuration file. The point is to compartmentalize configuration concerns to increase maintainability.

When you have a distinction such as /etc/httpd/conf vs /etc/httpd/conf.d, it is usually the case that /etc/httpd/conf contains various different kinds of configuration files, while a .d directory contains multiple instances of the same configuration file type (such as "modules to load", "sites to enable" etc), and the administrator can add and remove as needed.

Haakon
  • 686
  • 6
  • 3
  • 5
    but conf is also a directory, so if both are directories, what is the difference? You are right about ServerFault, is it possible to move it? – SCL Feb 25 '11 at 09:36
  • Added a bit about the distinction, hope it is not entirely confusing :-) – Haakon Feb 25 '11 at 10:10
  • 10
    The .d directories are also normally auto loaded. For example, cron will check cron.d and parse any files within there, the main apache config will have something like "include conf.d/*" which will include any files within conf.d on reload. It's also really handy for package management of modules. The package manager doesn't have to attempt to edit files, it just drops the config for the module into the correct .d directory, and then reloads the service. – Niall Donegan Feb 25 '11 at 11:45
  • 1
    @NiallDonegan generally, it's not true. E.g. glibc's dynamic linker only loads the files from `/etc/ld.so.conf.d/` if the main config (`/etc/ld.so.conf`) includes the `include /etc/ld.so.conf.d/*.conf` command or something similar. Same for `/etc/profile.d`, which is only traversed by the main `/etc/profile` script, and there are other examples. – Ruslan Jun 21 '20 at 14:51
15

The main driving force behind the existence of this directory naming convention is for easier package management of configuration files. Whether its rpm, deb or whatever, it is much easier (and probably safer) to be able to drop a file into a directory so that it is auto included into a program's configuration instead of trying to edit a global config file.

A good example of this is logrotate. In the directory /etc/logrotate.d are config files for practically every application you have installed that keeps a log in /var/log. Some are bunched into the syslog config because nearly every system has a messages, wtmp and lastlog file. But if you install Apache on your system, you need an easy way of automatically adding the config for rotating Apache's logs, so it just drops a config file called httpd in /etc/logrotate.d and logrotate is configured to include the files in that directory. Each one is owned by the package for the daemon and if you remove the package it will remove the file. Its basically a way of modularizing config files. Note that this needs to be supported by the program, its not something automatic that the system does for you or something. Usually programs that do it have a config directive called include that specify where that directory is located on the filesystem.

logrotate.d might even be the first place this convention was used outside of the init.d and rc.d directories for init scripts.

deltaray
  • 1,535
  • 10
  • 14