11

I have previously had apache2 installed, I upgraded to php5.5 and this broke my install so i tried to fix a few files. But that didnt work, I autoremoved apache but I still get this error when I try to install:

/etc/init.d/apache2: 64: .: Can't open /etc/apache2/envvars
/etc/init.d/apache2: 76: .: Can't open /etc/apache2/envvars
ERROR: APACHE_PID_FILE needs to be defined in /etc/apache2/envvars
invoke-rc.d: initscript apache2, action "restart" failed.

3 Answers 3

19

When you remove and re-install Apache it does not remove or over write config files.

see How can I restore configuration files?

Try:

sudo apt-get purge apache2
sudo apt-get install apache2

If that fails, update your question with error messages

1
  • Do you mean sudo apt-get purge apache2 and sudo apt-get install apache2? (If so, that should work, though I'd suggest sudo apt-get --purge --reinstall install apache2, which does it in "one step" and, more importantly, makes sure any necessary package files are downloaded before performing the original package removal.) Sep 5, 2014 at 15:31
4

Use command lines below:

sudo apt-get remove apache2
sudo apt-get purge apache2
sudo apt-get autoremove

And finally, install apache2 again: sudo apt-get -y install apache2.

2

Try:

sudo apt-get -o Dpkg::Options::="--force-confmiss" install --reinstall apache2.2-common

It will reinstall apache packages and restore all configuration files in /etc/apache2.

1
  • +1 This what you should do if you have to restore config files.
    – q9f
    Dec 21, 2014 at 20:55

You must log in to answer this question.

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