How to remove php 5.6
I just went ahead and added PHP7 to my server following a guide by using ondej’s PPA. Now I want to remove the old php so obviously I did sudo apt-get remove —purge php5 and ti seemed like everything went fine except it is not uninstalled. If I do php -v I get version 7 but I can still do php5 -v and get 5.6 or php5.6 -v and get the same thing. When I do sudo apt-get remove php5 (or php5.6) now I get that the package is not installed, but apparently is since I can execute the command.
x@x-server:~$ php -v PHP 7.0.6-1+donate.sury.org~trusty+1 (cli) ( NTS ) Copyright (c) 1997-2016 The PHP Group Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies x@x-server:~$ php5 -v PHP 5.6.21-1+donate.sury.org~trusty+1 (cli) Copyright (c) 1997-2016 The PHP Group Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies x@x-server:~$ php5.6 -v PHP 5.6.21-1+donate.sury.org~trusty+2 (cli) Copyright (c) 1997-2016 The PHP Group Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies x@x-server:~$ sudo apt-get remove --purge php5 php5.6 Reading package lists. Done Building dependency tree Reading state information. Done Package 'php5.6' is not installed, so not removed Package 'php5' is not installed, so not removed 0 upgraded, 0 newly installed, 0 to remove and 3 not upgraded. x@x-server:~$
How can I completely remove php5? And just because I know someone would ask — I want to remove it because I see that there are some processes running because of it that I don’t want to have.
1192 root 20 0 358756 30920 23568 S 0.0 2.1 0:00.12 apache2 1238 root 20 0 309316 29708 23448 S 0.0 2.0 0:00.11 php-fpm7.0 1176 root 20 0 166212 17848 14408 S 0.0 1.2 0:00.07 php-fpm5.6 1226 www-data 20 0 359312 15488 7656 S 0.0 1.1 0:00.09 apache2 1227 www-data 20 0 359008 14028 6380 S 0.0 1.0 0:00.00 apache2 1228 www-data 20 0 359008 13496 5856 S 0.0 0.9 0:00.00 apache2 1229 www-data 20 0 358788 9324 1964 S 0.0 0.6 0:00.00 apache2 1230 www-data 20 0 358788 9324 1964 S 0.0 0.6 0:00.00 apache2 1377 www-data 20 0 358788 9324 1964 S 0.0 0.6 0:00.00 apache2 1242 www-data 20 0 309316 8496 2236 S 0.0 0.6 0:00.00 php-fpm7.0 1243 www-data 20 0 309316 8496 2236 S 0.0 0.6 0:00.00 php-fpm7.0 1299 root 20 0 105680 6540 5468 S 0.0 0.4 0:00.06 sshd 1178 www-data 20 0 166212 5580 2140 S 0.0 0.4 0:00.00 php-fpm5.6 1179 www-data 20 0 166212 5580 2140 S 0.0 0.4 0:00.00 php-fpm5.6
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.
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.
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:
sudo apt-get remove –purge php7.2*
sudo apt-get purge php7.2*
sudo apt-get purge `dpkg -l | grep php7.2| awk '' |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
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.
How to completely remove PHP?
I need to clean up my server from PHP 5.3 packages (there are plenty of them) in order to be able to compile PHP 5.2. What is the easiest/safest method to get rid of them all?
10 Answers 10
This method is not advised to be used without careful review. Read below comments.
This should completely remove any package with a name that starts with php and anything related to it.
DON’T PRESS y UNTIL YOU ENSURE that in the removing packages list there are no other packages (besides related to php packages), like:
php-common* python-openssl* php-curl* . and tons of packages
If so, type n , copy the list (& tidy up from the unrelated packages), and manually remove them:
sudo apt-get purge php-common* php-curl* . and tons of packages
OK thanks both of you. I just chosen your answer because Marco does not seem to have lack of Karma 🙂
I do not recommend running sudo apt-get purge php* .
That was scary! Fortunately, I didn’t type the -y option, because it chose about hundred of packages without php in their name.
sudo apt-get purge `dpkg -l | grep php| awk '' |tr "\n" " "`
How it works:
First, a list of packages is generated using this series of commands: dpkg -l | grep php| awk » |tr «\n» » » .
Hint: You can run this part of the command in your terminal to see what packages would get removed. You should get something like: libapache2-mod-php5 php5 php5-cli php5-common php5-json
Finally, when you run the full command, this list of packages gets passed to sudo apt-get purge, removing all of the packages.
Hint: If it feels safer to you, you could just as easily run them separately, and copy+paste the list of packages to remove like so: sudo apt-get purge libapache2-mod-php5 php5 php5-cli php5-common php5-json
Sounds like you’re suggesting one syntax is bad because too wide but do you mind explaining what your command does, so people may be able to judge if that’s appropriate before running it?
If you’ve upgraded your OS and doing this to get clean state — don’t forget to remove repository(ies) ppa:ondrej/php if you used them before installing PHP again, otherwise you will endup with broken installs 🙂
I also agree with @DarkStar1. This answer should be the accepted answer. I ran RobbinJ’s answer and it didn’t end well. It totally destroyed my system. Luckily, I made a backup image of the system before running his command. So, I was able to restore my system.
You’ll probably want to purge all the php* packages from your system. Something with a wild-card should work
You may be interested in How to rollback to PHP 5.2 for where to go next.
First, you have to remove Apache and all of its dependencies with:
sudo apt-get purge apache2 php5 libapache2-mod-php5 mysql-server libapache2-mod-auth-mysql php5-mysql phpmyadmin
sudo rm -rf /etc/apache2; rm -rf /etc/php5; rm -rf /var/lib/mysql; rm etc/mysql
If you have any issues with phpMyAdmin, try entering this into the Terminal:
dpkg-reconfigure phpmyadmin
***Note to those who copy-paste without reading carefully, this will also remove apache, which is not what OP asked for
sudo apt-get -y purge libapache2-mod-php5 libapache2-mod-php5filter libexpect-php5 libgv-php5 libow-php5 php5 php5-adodb php5-auth-pam php5-cgi php5-cli php5-common php5-curl php5-dbg php5-enchant php5-exactimage php5-ffmpeg php5-fpm php5-geoip php5-gmp php5-idn php5-imagick php5-imap php5-interbase php5-intl php5-json php5-lasso php5-ldap php5-librdf php5-mapscript php5-memcache php5-memcached php5-mhash php5-midgard2 php5-ming php5-mssql php5-mysql php5-mysqlnd php5-odbc php5-pgsql php5-ps php5-pspell php5-radius php5-recode php5-remctl php5-rrd php5-sasl php5-snmp php5-sqlite php5-suhosin php5-svn php5-sybase php5-tidy php5-tokyo-tyrant php5-uuid php5-xcache php5-xdebug php5-xmlrpc php5-xsl
In your case, you could search for all the packages:
sudo aptitude search php5|awk |grep -v i386|grep -v "^A"|tr "\n" " "
How To completely uninstall PHP 8.X in ubuntu?
Hello Guy How are you all? Hope You all are fine. Today in this tutorial we are going to learn about How To completely uninstall PHP in ubuntu? In this tutorial, We will Discuss all possible methods to uninstall PHP from the ubuntu server. So Let’s start this article without wasting your time.
How To completely uninstall PHP 8.X in ubuntu?
How To completely uninstall PHP in ubuntu?
To completely uninstall PHP in ubuntu Just Run purge, autoclean and autoremove command in your server, and this command will completely uninstall your PHP from your Ubuntu server. So follow all commands one by one. First Of all, You just need to run the purge command. Just run this command in your terminal: sudo apt-get purge php8.* The above command will Uninstall Any of the PHP 8.X versions of PHP installed on your Server. Now we need to cleans obsolete deb-packages to do so we need to run autoclean command: sudo apt-get autoclean After that, we need to remove orphaned packages that are no longer needed from the system so run autoremove command just like this: sudo apt-get autoremove And Now, You have Successfully Uninstalled PHP from your system. Thank You.
completely uninstall PHP in ubuntu
Solution 1: Run this command
To completely uninstall PHP in ubuntu Just Run purge, autoclean and autoremove command in your server, and this command will completely uninstall your PHP from your Ubuntu server. So follow all commands one by one.
First Of all, You just need to run the purge command. Just run this command in your terminal.
The above command will Uninstall Any of the PHP 8.X versions of PHP installed on your Server. Now we need to cleans obsolete deb-packages to do so we need to run autoclean command.
After that, we need to remove orphaned packages that are no longer needed from the system so run autoremove command just like this.
You can run this all command together
sudo apt-get purge php8.* sudo apt-get autoclean sudo apt-get autoremove
And Now, You have Successfully Uninstalled PHP from your system. Thank You.
Solution 2: Follow this command
You Can use this all command to remove PHP from your system.
sudo apt-get purge `dpkg -l | grep php8.1| awk '' |tr "\n" " "` sudo apt-get purge php8.* sudo apt-get autoremove --purge whereis php sudo rm -rf /etc/php
Above all Command will completely remove PHP from your system. Thanks.
Conclusion
It’s all About this error. I hope We Have solved Your error. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you?