Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ubuntu 16.04 I uninstalled apache2 but can't reinstall it now

Tags:

ubuntu

apache2

I have a problem on an ubuntu 16.04 server that I set up. I suspected that I had made a number of errors when I installed and configured apache2 originally because it was not behaving the way it normally does.

I decided to uninstall apache2 completely, including removing the config files, so that I could do a "fresh" installation.

I ran these commands:- service apache2 stop sudo apt-get purge apache2 apache2-utils apache2.2-bin apache2-common sudo apt-get autoremove --purge whereis apache2 rm -Rf /etc/apache2 /usr/lib/apache2 /usr/include/apache2

After the above, I did another whereis and decided to remove more stuff rm -Rf /usr/sbin/apache2 /usr/share/apache2 /usr/share/man/man8/apache2.8.gz

Then everything was gone!

I rebooted the server.

However, when I now say: apt install apache2

Reading package lists... Done Building dependency tree
Reading state information... Done apache2 is already the newest version (2.4.18-2ubuntu3.9). 0 upgraded, 0 newly installed, 0 to remove and 2 not upgraded.

But I checked and /etc/apache2, etc is gone. It is as if it is telling me apache2 is still there?

I'm confused! Help!

like image 943
Jan Lamprecht Avatar asked Dec 11 '18 20:12

Jan Lamprecht


People also ask

Can I uninstall apache?

Procedure. To uninstall Apache as a service, open a Command Prompt window. Navigate to the default Apache installation directory, for example, C:\Program Files\Apache Group\Apache or wherever apache.exe is located. At the command prompt, type apache -u.


1 Answers

Follow these steps to remove the apache2 service using Terminal:

  1. First stop the apache2 service if it is running with: sudo service apache2 stop
  2. Now remove and cleanup all the apache2 packages with:

    sudo apt-get purge apache2 apache2-utils apache2.2-bin apache2-common
    //or 
    sudo apt-get purge apache2 apache2-utils apache2-bin apache2.2-common
    
  3. Finally, run sudo apt-get autoremove just in case any other cleanup in needed

You can do the following two tests to confirm apache has been removed:

  1. which apache2 - should return a blank line
  2. sudo service apache2 start - should return apache2: unrecognized service

answer from here

like image 56
GHOST Avatar answered Nov 15 '22 10:11

GHOST