While experimenting with mod_python, I ended up completely hosing my local Apache install. I had the configuration files in a bad state, so I thought the easiest approach would be to drop all of /etc/apache2, remove the Apache packages then re-install them. But once that happened, /etc/apache2 wasn’t remade as I had hoped! When I tried to start or stop Apache, it spat back:
1 | .: 44: Can't open /etc/apache2/envvars |
Oh right, thanks… The problem, I believe, was that I hadn’t really removed all the right packages and hadn’t used “–purge”. So here’s what I did to erase Apache’s memory of my mistakes:
Find and drop all Apache packages
1 2 3 4 5 6 7 8 9 10 | APACHE_PKGS=`sudo dpkg --get-selections | grep apache | cut -f 1` # Make sure things are sane: echo $APACHE_PKGS # Example output: apache2 apache2-mpm-prefork apache2-utils apache2.2-common \ # libapache2-mod-php5 libapache2-mod-python libapache2-svn # Likely if you have a Python application: # libapache2-mod-python libapache2-mod-python-doc libapache2-mod-wsgi # Or if you roll with the PHP: # libapache2-mod-php5 sudo apt-get remove --purge $APACHE_PKGS |
Re-install Apache
1 2 3 | # You might want to consider not re-installing the whole list; # instead dump it out, audit, and install what you need: sudo apt-get install $APACHE_PKGS |
After this, all the configuration files were back, and I had a default Apache install.
Note: this was performed on an Ubuntu 9.04 system running 2.6.24-23-xen kernel. YMMV.
No related posts.
Related posts brought to you by Yet Another Related Posts Plugin.









Paint another laptop on the front of your fighter plane: you saved my bacon!
i have get this msg while running above commands “FusionForge Could Not Connect to Database: ”
help pls …
My Ubuntu version is 10.04
@prabhakar This sounds like more an issue to ask folks at FusionForge, I have not used that application. What command did you run just before the error was thrown?
@prabhakar
it worked for me under 11.04 (natty), so most prob it will under 10.04 as well. So thanx to Sammy for his post -> it helped.
The only thing I wonder, is why the installation routine for apache2 doesn’t purge and reinstall the configuration files (I thought the purge was exactly meant for that). For me t h a t doesn’t make less sense . . . but that’ll be strange developers’ ideas that we users are not supposed to bring into question
. As a ‘normal’ user I would expect to be the main package (being purged and installed completely) and then for pros additionally the possibility to manage single packs like separately and not the other way round . . .
your instruction and reboot helps, thx!
Thank you! This worked great in 10.04.
This worked great! Thanks
I tried so much I didn’t know what to try next but with your help I sorted the problem in minutes thanks for all Sean
Lifesaver!
Worked like a charm on 10.04. Seriously, your link needs to be on top for “deleted /etc/apache2″
Thanks!
Pingback: TheSlim » Как полностью удалить Apache в Ubuntu
does this works on ubuntu 10.10 server?
I love you!! … saved me a shedload of hassle .. thanks…
Thanks a lot buddy! You saved my day
You are awesome! I looked everywhere for the fix and you were the only one with it. Thanks!
Someone build a statue for this guy. You’ve saved my ass
you made me breath easy!!!! thanks!!!!
Super! Works!
Mate!!! Thanks so much!!! It worked like a dream! Thanks again
Thank you – this was just what I needed, you saved me a lot of time.