Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
/etc/apache2/envvars is in apache2.2-common, have you reinstalled that package too? Like with command sudo apt-get --reinstall install apache2.2-common – LGB Feb 14 '11 at 7:07
up vote 57 down vote accepted

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.

share|improve this answer
This also doesn't work. It says that apache2 is already installed and the purge doesn't remove the config file in etc/apache2. In fact the purge complains that it can't envvars too. – seadowg Feb 14 '11 at 10:31
Has reinstalling apache2.2-common with the option about to replace missing conf files worked for you? – ajmitch Feb 17 '11 at 0:51
Almost a year later and found this, thank you very much. – nerdwaller Dec 6 '12 at 16:35
helped a lot, but package apache2.2-common doesn't exist anymore....did the same sequence just with package apache2 – Jürgen Zornig Jun 20 '14 at 7:20
Not tested with Ubuntu, but under Debian to restore config files which are managed by ucf the --force-confmiss option won't work, you have to use sudo UCF_FORCE_CONFFMISS=1 apt-get --reinstall install [pkgname]. – Skippy le Grand Gourou Feb 23 '15 at 18:07

run the following command first

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

then run

sudo apt-get install apache2

it worked for me

share|improve this answer
This will delete all your apache configs. :( – tokam Dec 5 '13 at 12:45
@tokam Yes, see the question. – Felix Rabe Apr 1 '14 at 7:11

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
share|improve this answer
right, you need to remove all related packages in order to reinstall config files – hmontoliu Feb 14 '15 at 17:42

try this

apt-get -f install

then run

sudo apt-get install apache2

Edit: or possibly

sudo apt-get purge apache2
sudo apt-get install apache2
share|improve this answer

protected by Braiam Jan 23 '14 at 13:24

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.