Is there any way to reset the `httpd.conf` in CentOS to the original/default version?

Shorter answer:

You could simply erase or move the httpd.conf file you adjusted and then run the following command and it will be reinstalled:

yum reinstall httpd

Longer answer:

But if you want to be a bit more methodical about it, you could follow the ideas and concepts shown on this page.

First, check what package installed httpd.conf by running this command:

rpm -qf /etc/httpd/conf/httpd.conf

Of course that would show you that the httpd package installed it, but it will also give you additional version info. So now you can verify what was changed between the initial install from the RPM to when you adjusted it by verifying it with RPM like this:

rpm -V httpd

Output would most likely show you /etc/httpd/conf/httpd.conf preceded by some verification info which should look like this:

S.5....T.  c /etc/httpd/conf/httpd.conf

That can be translated as the Size was changed, the MD5 checksum is different and the Time is different. More details on what those one letter codes mean are below:

S file Size differs
M Mode differs (includes permissions and file type)
5 MD5 sum differs
D Device major/minor number mismatch
L readLink(2) path mismatch
U User ownership differs
G Group ownership differs
T mTime differs
P caPabilities differ

But the long and short of it is you will be able to see exactly what files from the httpd package had changed and for what reason. Which could be useful to know if you happened to add or changed any file other than httpd.conf and it slipped your mind.

Now you might want to remove the current httpd.conf like this:

sudo rm /etc/httpd/conf/httpd.conf

But I would recommend keeping a copy of it for reference like this:

sudo mv /etc/httpd/conf/httpd.conf ~/httpd.conf.modified

That would move httpd.conf to your home directory and rename it httpd.conf.modified.

Finally, you can reinstall httpd like this:

yum reinstall httpd

And your Apache httpd.conf config file should be back to it’s original, untouched RPM state.


@JakeGould's answer is great but to be more explicit:

yum reinstall httpd will only restore missing files, not the changed configs. By moving/removing the old configuration file first, that allowed yum reinstall to restore the file.

Alternatively, you could use the method shown here: How to force `yum reinstall` to overwrite changed files in a `/var` sub-directory?

Tags:

Centos 6

Httpd