How can I reinstall Apache HTTPD after deleting some of the configuration files?

I recently was messing around with my Apache config and wanted to reinstall so I could start from fresh. I followed some forum posts about reinstalling the apache2 package and this ended up deleting my /etc/apache2 folder.

Now matter how many things I try I can't seem to do a full wipe of the Apache install and then reinstall. sudo apt-get install apache2 or reinstall doesn't do anything. I can't seem to remove it using Synaptic either.

Is there anything I can do to have a fresh Apache install on my computer again?


To replace configuration files that have been deleted, without purging the package, you can do

sudo apt-get -o DPkg::Options::="--force-confmiss" --reinstall install apache2

To fully remove the apache2 config files, you should

sudo apt-get purge apache2

which will then let you reinstall it in the usual way with

sudo apt-get install apache2

Purge is required to remove all the config files - if you delete the config files but only remove the package, then this is remembered & missing config files are not reinstalled by default.


run the following command first

sudo apt-get remove --purge apache2 apache2-utils

then run

sudo apt-get install apache2

it worked for me


Remove Apache2 files...

sudo apt-get remove --purge apache2*

Clean install

sudo apt-get --reinstall install apache2.2-common
sudo apt-get --reinstall install apache2