38

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?

  • 1
    /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
76

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.

|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
  • 1
    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
5

run the following command first

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

then run

sudo apt-get install apache2

it worked for me

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

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

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
|improve this answer|||||

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