How to uninstall PHP apache2 and MySQL on linux server

Cropped image of It specialist working on code

1. Remove PHP and its associated packages

sudo apt-get remove –purge php* 
sudo apt-get purge php*
sudo apt-get autoremove
sudo apt-get autoclean
sudo apt-get remove dbconfig-php
sudo apt-get dist-upgrade

Now find the installed PHP packages by running following command

sudo dpkg --get-selections | grep php | cut -f 1

If you get any result then run the command given below.

sudo apt-get remove --purge <package name from the output of previous command>

Locate PHP modules file or folder if it is still installed

sudo whereis php

If you get any file or directory path then remove it by running command given below

sudo rm -rf <file or directory path from the output of previous command>

2. Remove Apache2 and its associated packages

First of all stop apache service

sudo service apache2 stop

Remove apache and packages associated to it

sudo apt-get purge apache2 apache2-utils apache2.2-bin apache2-common
sudo apt-get autoremove

Now find the installed apache packages by running following command

sudo dpkg --get-selections | grep apache | cut -f 1

If you get any result then run the command given below.

sudo apt-get remove --purge <package name from the output of previous command>

Locate apache module file or folder if it is still installed

sudo whereis apache

If you get any file or directory path then remove it by running command given below

sudo rm -rf <file or directory path from output of previous command>

3. Remove MySQL and its associated packages

sudo apt-get remove –purge mysql*
sudo apt-get purge mysql*
sudo apt-get autoremove
sudo apt-get autoclean
sudo apt-get remove dbconfig-php
sudo apt-get dist-upgrade

Now find the installed mysql packages by running following command

sudo dpkg --get-selections | grep mysql | cut -f 1

If you find any result then run the following command

sudo apt-get remove --purge <package name from the output of previous command>

Locate mysql module file or folder if it is still installed

sudo whereis mysql

If you get any file or directory path then remove it by running command given below

sudo rm -rf <file or directory path from the output of previous command>

Leave a Reply to Anonymous Cancel reply

Your email address will not be published. Required fields are marked *