How to completely reset an Apache instance in Ubuntu
While experimenting with mod_python, I ended up completely hosing my local Apache installed. I had the configuration files in a bad state, so I thought I would just drop all of /etc/apache2, remove Apache, and re-install it. But once that happened, /etc/apache2 wasn’t remade! When I tried to start or stop Apache, it spat back:
1 | .: 44: Can't open /etc/apache2/envvars |
Oh right, thanks… So here’s what I did to erase Apache’s memory of my mistakes:
- Find and drop all Apache packages:
1
2sudo dpkg --get-selections | grep apache
sudo apt-get remove --purge apache2 apache2-mpm-worker apache2-threaded-dev apache2-utils apache2.2-common libapache2-mod-python libapache2-mod-python-doc libapache2-mod-wsgi - Re-install Apache:
1sudo apt-get install apache2 libapache2-mod-python libapache2-mod-wsgi libapache2-mod-python-doc
After this, all the configuration files were back, and I had a default Apache install.
Possibly Related (no promises):
- Quick tips for NVIDIA and ATI graphics configuration repairs on Ubuntu
- Using a Juniper SSL VPN on Ubuntu
- 64-bit Ubuntu: Not a problem
- Useful grep incantations
- Permanently remember password for gksudo
Related posts brought to you by Yet Another Related Posts Plugin.
February 22, 2009 - 2:02 AM








Moos
February 23, 2009 | 1:00 PMWould have “dpkg-reconfigure apache2″ worked?
victortns
May 4, 2009 | 2:15 PMi have the same error and i solve the problem with your text, thanks
Samuel Huckins
May 4, 2009 | 4:50 PM@Moos: Not sure, will have to try and report next time I fubar Apache
@victortns: Glad to hear it! That’s exactly why I write this blog
lohitha
May 26, 2009 | 12:57 AMI had the same issue with a corrupted apache installation.
I could solve it with your suggestions.
Thanx a lot for the info
Rickey Moore
July 15, 2009 | 3:03 AMThanks!!!!!!!! That saved my bacon. It was brutal and scary though. BUT! I have all of my files back and that is what counts. Thanks! Ric
joseliki
July 22, 2009 | 6:08 AMthank you so much!!!! my server it works again
phreakincool
August 2, 2009 | 3:18 AMThanks!
Zet0
August 3, 2009 | 4:23 PMThx a lot !
Comet
August 8, 2009 | 4:37 PMthanks so much for this informative post. I had numerous problems with my installation, mostly due to deleting the default virtual host entry in webmin. tried reinstalling apache numerous times, but this did the trick PERFECTLY. THANKS A MILLION!
Kallesson
September 4, 2009 | 9:27 PMThank god (well I guess you are god) for this post. Been looking for ages for an easy way to do this!
tmac
September 18, 2009 | 7:21 PMVery cool, just saved me a bunch of time on a hosed install.
Jensca
September 26, 2009 | 4:33 PMHi this worked for me, thanks, can i copy to my personaly blog and link to yours?
Samuel Huckins
September 26, 2009 | 8:21 PM@Jensca Sure, link away! Glad it helped.
Fatman
October 15, 2009 | 11:13 AMI had the same problem. Thanks. Would have taken me ages to guess that.
Though actually my Apache config wasn’t hosed. I just felt it was “unclean” and I wanted to start over.
Ben Herman
October 21, 2009 | 8:19 AMThanks so much have a box that has been up 151 days now that i thought i would have to take down and reload due to a massive Apache fubar! This tutorial saved the day, and my up time count!
Samuel Huckins
October 21, 2009 | 8:21 AM@Ben Herman: Awesome! It’s all about the uptime, baby
Ntropy
October 22, 2009 | 7:56 PMThank you. After hours of failure, this process worked. Truly appreciated.
Ben Herman
October 26, 2009 | 12:39 PMWanted to let you know I put these instructions up on my blog and posted back to yours giving you credit. Thanks again.
John
November 18, 2009 | 12:00 PMYou Sir, are a hero.
Malaysia
December 30, 2009 | 11:02 AMu r hero bro! TQ VERY MUCH!!
Ganesh
January 11, 2010 | 12:40 AMI new to ubuntu, and I m tryong to reinstall apache for 2 days. but u r command did all for me to config apache.
thx dude!!
Arema
January 11, 2010 | 11:27 PMI had exactly the same problem: out of desperation I manually sudo and deleted the directory apache2. And then I was at a lost as to what to do next because installation did not return the config files. Thanks for this posting!