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
- 64-bit Ubuntu: Not a problem
- Permanently remember password for gksudo
Related posts brought to you by Yet Another Related Posts Plugin.








Would have “dpkg-reconfigure apache2″ worked?
i have the same error and i solve the problem with your text, thanks
@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
I had the same issue with a corrupted apache installation.
I could solve it with your suggestions.
Thanx a lot for the info
Thanks!!!!!!!! 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
thank you so much!!!! my server it works again
Thanks!
Thx a lot !
thanks 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!
Thank god (well I guess you are god) for this post. Been looking for ages for an easy way to do this!
Very cool, just saved me a bunch of time on a hosed install.
Hi this worked for me, thanks, can i copy to my personaly blog and link to yours?
@Jensca Sure, link away! Glad it helped.
I 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.
Thanks 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!
@Ben Herman: Awesome! It’s all about the uptime, baby
Thank you. After hours of failure, this process worked. Truly appreciated.
Pingback: Can’t open /etc/apache2/envvars
Wanted to let you know I put these instructions up on my blog and posted back to yours giving you credit. Thanks again.
You Sir, are a hero.
u r hero bro! TQ VERY MUCH!!
I 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!!
I 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!
Thanks a lot…for this information
Thanks for posting this! Now I can start off with a clean slate.
Hey Thanks for that.. I was in the same situation and got apache back up working again.!
cool.
great !!! thanks