0

In the last couple days I have been setting up a Rackspace CentOS-based webserver which I took over from another developer. Amongst other things, I noticed that in the httpd directory, there were two directories. One is a /conf and the other is /conf.d While the former seemed to contain the .conf files applicable to the webserver Apache in general, the latter seemed to contain {name}.conf files for several websites located on the server. In this case, {name} - folder where the website is stored.

What is more, whenever I would enter the IP address for the server in the browser, it would go to a particular one of these sites. Upon editing the .conf of this site to point to the directory of another site, the routing changed.

Does anyone know what is the purpose of these files? How does Apache parse through them? Does it select the first folder alphabetically and refer the user to that site if he enters IP in the browser?

1
  • You should learn something about dns. It would help you understanding how Apache choose sites
    – Jakuje
    Aug 11, 2015 at 20:23

1 Answer 1

1

It's a way to organise your config into logical files. It's generally easier to find ssl.conf instead of parsing through 1000 lines of httpd.conf for the ssl section.

On centos, conf/httpd.conf will include conf.d/*.conf. This is probably loaded in same order the shell globs *.conf which basically amounts to alphabetical order (but I've never checked the code specifically).

This setup allows you to create any file name, like mydomain.com.conf and place all the virtualhost settings for that domain in the one file.

Removal of config then is as simple as rm mydomain.com.conf

3
  • That make sense. Do you know the order in which it parses the conf.d directory? That is, why was it assigning a particular site as "first" and displayed it?
    – ArtforLife
    Aug 11, 2015 at 20:34
  • The order will likely be ls /etc/httpd/conf.d/*.conf. If you are talking about virtualhosting sites it's likely more complicated than simply order as IP addresses, names, defaults, and order come into play.
    – Matt
    Aug 11, 2015 at 20:40
  • The only way to say for sure is if you post the configs and what you changed
    – Matt
    Aug 11, 2015 at 20:41

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.