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, 2011 at 7:07

4 Answers 4


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.

  • 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, 2011 at 10:31
  • Has reinstalling apache2.2-common with the option about to replace missing conf files worked for you?
    – ajmitch
    Feb 17, 2011 at 0:51
  • Almost a year later and found this, thank you very much.
    – nerdwaller
    Dec 6, 2012 at 16:35
  • 1
    helped a lot, but package apache2.2-common doesn't exist anymore....did the same sequence just with package apache2 Jun 20, 2014 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]. Feb 23, 2015 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

  • 3
    This will delete all your apache configs. :(
    – tokam
    Dec 5, 2013 at 12:45
  • 5
    @tokam Yes, see the question.
    – Felix Rabe
    Apr 1, 2014 at 7:11
  • This work and delete apache conf files. sites-enable and sites-available directories and conf files are kept! Nov 18, 2023 at 15:32

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
  • right, you need to remove all related packages in order to reinstall config files
    – hmontoliu
    Feb 14, 2015 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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .