How to Uninstall PHP, Apache and MySQL on Ubuntu 20.04 LTS

How to Uninstall PHP, Apache and MySQL on Ubuntu 20.04 LTS
How to Uninstall PHP, Apache and MySQL on Ubuntu 20.04 LTS

This blog will help you how to uninstall or remove PHP, Apache and MySQL on Ubuntu LTS of any version. Step by step commands has been given in this blog. So if your are facing any issue I suggest you to please watch the video that is provided below.
First we remove PHP from Ubuntu.

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
Warning below command will do completely remove any package with a name that starts with php and anything related to it.

sudo apt-get purge 'php*'
So, DON’T PRESS “y” UNTIL YOU ENSURE that in the removing packages list there are no other packages (besides related to php packages), like:
Suppose if you are removing php7.2 then use the below commands.

sudo apt-get remove –purge php7.2*
sudo apt-get purge php7.2*
sudo apt-get purge `dpkg -l | grep php7.2| awk '{print $2}' |tr "n" " "`
whereis php
sudo rm -rf /etc/php
sudo apt-get autoremove
sudo apt-get autoclean
sudo apt-get remove dbconfig-php
sudo apt-get dist-upgrade

Now we remove Apache2  from Ubuntu.

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


Finally we are removing MySql from Ubuntu.

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

  Removing directories from their respective default locations.

sudo rm -rf /etc/apache2
sudo rm -rf /etc/php
sudo rm -rf /var/lib/mysql
sudo rm etc/mysql


Conclusion

Congratulation you have successfully uninstalled or removed LAMP- PHP, apache2, and Mysql from Ubuntu Operating System. Let me know in the comment box if you are facing any difficulties while executing above commands.

Also Read:- How To Install Linux, Apache, MySQL, PHP (LAMP) on Ubuntu

Also Read:-  How to Install MySQL 8.0 on Ubuntu 16.04 LTS ??

Also Read:- Uninstall or Remove MySql 5.7 from Ubuntu 20.04 LTS.

Leave a Reply

Your email address will not be published.