0

I've had to replace my server, the old one runs CentOS and the new one runs Debian.

In Debian, Apache has apache2.conf as its main configuration file with a number of others linked to it. In CentOS there is only one configuration file for Apache, httpd.conf.

Question: may I use the old httpd.conf file in the new server and if so, how do I ensure that the httpd.conf settings will prevail over the existing configuration files?

The post at Ubuntu Apache: httpd.conf or apache2.conf? indicates that the existing configuration files should not be changed in case of updates.

I realize that my custom configuration can be put into /etc/apache2/conf.d however, it is not clear to me whether the other configuration files in that location would conflict with it.

1

Fundamentally there's nothing different between the two. You can rename the old httpd.conf to replace apache2.conf entirely (suggest you back up apache2.conf first). The new apache2.conf file directly references all other config files so replacing it with a monolithic (single) config file will completely overwrite that structure back to the one you're used to. There's no danger of the "new" settings overriding your "old" settings.

But

Firstly check if the version of Apache and all the modules are the same. If not, your config may not be compatible with the Debian binaries.

Secondly consider if this is really what you want. The "new" apache.conf is designed to work with the wider system (such as apt / dpkg). For example installing Apache modules will automatically install the config for them as well.

Best Practice

Don't try to simply include your old file. It will most likely fail. The best thing to do is to look at how Debian has structured its configuration then work through your old config file and try to slice it up so that it fits into the new structure. This does mean you will need to understand everything in your config file (not a bad thing anyway).

0

Further to couling's answer, in case you do wish to add your own configuration file in a Debian-type distribution without altering the existing settings, this is how I managed to do it:

  1. Put your configuration file (the name of this file must end with .conf) in the folder /etc/apache2/sites-available.
  2. Go to the sites-available directory and type sudo a2ensite [name-of-your-file].conf.
  3. Reload the configuration by typing sudo service apache2 reload.

The above process puts a symbolic link file in the location /etc/apache2/sites-enabled. To override the default server settings, delete the existing file which is named 000-default.conf (you should take a copy of this file first).

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.