Search code examples
azureubuntuapache2azure-virtual-machineputty

apache2 server showing me the current installed version in my azure vm even it is uninstalled


I have the Azure VM is of Linux (Ubuntu) -20.04.

Long back, installed the apache2 (version is 2.4.41). Now I have tried to uninstall apache2, nginx but when I enter apache2 -v command in the azure vm (putty) - it is still showing me the current version of that server. Why?

Commands I used:

sudo apt remove nginx
sudo apt remove apache2
sudo apt autoremove
apache2 -v

I already uninstalled right but why it is showing me?enter image description here

Update:

which apache2 command told me the output /usr/sbin/apache2

enter image description here

I tried to delete apache2 from /usr/sbin/ path, it shown me below output:

/sbin$ sudo apt remove apache2
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package 'apache2' is not installed, so not removed
0 upgraded, 0 newly installed, 0 to remove and 281 not upgraded.

If I enter apache2 -v, it shows me the current installed version:

/sbin$ apache2 -v
Server version: Apache/2.4.41 (Ubuntu)
Server built:   2023-03-08T17:32:54

If you see color coding of the output in one of the above screenshot, it shows apache2 color in green color. Green color determines the executable file or recognized data file.

Is that just a executable file which is not installed? Am I Correct?


Solution

  • In my virtual machine I have Apache server like below:

    sudo systemctl status apache2
    ● apache2.service - The Apache HTTP Server
         Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
         Active: active (running) since Tue 2023-11-28 16:45:09 UTC; 7min ago
           Docs: https://httpd.apache.org/docs/2.4/
       Main PID: 2955 (apache2)
          Tasks: 55 (limit: 19118)
         Memory: 17.3M
         CGroup: /system.slice/apache2.service
                 ├─2955 /usr/sbin/apache2 -k start
                 ├─2957 /usr/sbin/apache2 -k start
                 └─2958 /usr/sbin/apache2 -k start
    
    Nov 28 16:45:09 vm2 systemd[1]: Starting The Apache HTTP Server...
    Nov 28 16:45:09 vm2 systemd[1]: Started The Apache HTTP Server.
    imran123@vm2:~$ apache2 -v
    Server version: Apache/2.4.41 (Ubuntu)
    Server built:   2023-10-26T13:54:09
    

    enter image description here

    To remove Apache, you can make use of below command:

    sudo systemctl stop apache2
    sudo apt-get purge apache2
    sudo apt-get autoremove
    apache2 -v
    

    Output:

    imrxxxx:~$ sudo apt-get autoremove
    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    The following packages will be REMOVED:
      apache2-bin apache2-data apache2-utils libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap libjansson4
      liblua5.2-0 ssl-cert
    0 upgraded, 0 newly installed, 10 to remove and 34 not upgraded.
    After this operation, 7575 kB disk space will be freed.
    Do you want to continue? [Y/n] y
    (Reading database ... 59414 files and directories currently installed.)
    Removing apache2-bin (2.4.41-4ubuntu3.15) ...
    Removing apache2-data (2.4.41-4ubuntu3.15) ...
    Removing apache2-utils (2.4.41-4ubuntu3.15) ...
    Removing libaprutil1-dbd-sqlite3:amd64 (1.6.1-4ubuntu2.2) ...
    Removing libaprutil1-ldap:amd64 (1.6.1-4ubuntu2.2) ...
    Removing libaprutil1:amd64 (1.6.1-4ubuntu2.2) ...
    Removing libapr1:amd64 (1.6.5-1ubuntu1) ...
    Removing libjansson4:amd64 (2.12-1build1) ...
    Removing liblua5.2-0:amd64 (5.2.4-1.1build3) ...
    Removing ssl-cert (1.0.39) ...
    Processing triggers for man-db (2.9.1-1) ...
    Processing triggers for libc-bin (2.31-0ubuntu9.12) ...
    imran123@vm2:~$ apache2 -v
    -bash: /usr/sbin/apache2: No such file or directory
    

    enter image description here