I remove apache from my machine following these steps:
sudo apt-get remove apache2*
sudo apt-get autoremove
sudo rm -Rf /etc/apache2
I was able to remove it successfully but when I tried to install it again I got this error:
/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.
I tried to fix it whit this command
sudo apt-get --purge --reinstall install apache2
but I got the same error.
Best Answer
apt-get remove does not remove configuration files, and you probably touched that file and messed it up so reinstalling without purging configuration will not work. So try this approach instead:
and then:
envvars file comes in apache2 package and default should include all the necessary variables, you can brwose and check it yourself from envvars search at packages.ubuntu.com