Is there any way to reset the `httpd.conf` in CentOS to the original/default version?
Emily Wong
I was learning server installation by creating a web server in VMware, I don’t know what changes I made to httpd.conf.
Is there any way to reset all the configuration for httpd.conf to default?
Command used:
vi /etc/httpd/conf/httpd.conf- Updated
ServerNametolocalhost service httpd restartchkconfig httpd onservice httpd restart
2 Answers
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 httpdLonger 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.confOf 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 httpdOutput 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.confThat 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 differBut 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.confBut I would recommend keeping a copy of it for reference like this:
sudo mv /etc/httpd/conf/httpd.conf ~/httpd.conf.modifiedThat would move httpd.conf to your home directory and rename it httpd.conf.modified.
Finally, you can reinstall httpd like this:
yum reinstall httpdAnd 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?
0