I'm configuring Apache under a Debian based Linux distribution. I would like to configure it in such a way that my configuration changes don't get in the way of Apache upgrades. I would like to do it in such a way that I don't have to edit any of the configuration files that come with the distribution.

I know that I can put the configuration for my websites in the /etc/apache2/sites-available directory and then enable them with a2ensite. Similarly, I can enable the modules I want with a2enmod.

What happens if I write new configuration files into /etc/apache2/conf-available/ and then use a2enconf to enable them? Specifically, will the be able to override settings that are specified in other configuration files. For example /etc/apache2/apache2.conf specifies Timeout 300. If I put Timeout 500 in my configuration file, will it override the earlier declaration? Would there be any Apache configuration directives for which using this override technique would not work?

  • 1
    Just a sidenote: everything you're talking about is Debian's custom system for configuring Apache. None of that stuff is part of the official software. The official software just comes with a single, easy to read configuration file that doesn't need any special modifications between versions (except maybe adding new directives to enable new functionality). – Chris S Jan 3 '14 at 21:48

If current configuration uses inclusion from certain directory by mask - yes, you can.

Usually that looks like that:

Include etc/apache22/Includes/*.conf

So you just copy your configuration in that directory and keep in mind that apache include includes in the lexical order. If you want to override some values already set, just name your file zzzzzzzzz.conf


Based on an encouraging answer from Kondybas, I went ahead and experimented with this. I only ran into two problems:

  1. The Listen directive cannot be "overridden". By its very nature it is an "additive" directive. What stumped my for a while was that it can't even be specified twice for the same port number. The following will cause an error stating that port 80 is already in use and Apache cannot be started. The solution for me was to remove the Listen directive from my own config and rely only on the one provided by the distribution.

    Listen 80
    Listen 80
  2. The PidFile directive cannot be overridden on a Debian based system without also modifying the /etc/apache2/envvars config file. The process id file must match between that config file and the Apache config file or Apache will not start using Debian's service command.

Other than that, all the other directives that I have tried work fine in a config file that specifies them a second time.

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.