Ubuntu: How to remove php 5.6



Question:

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  


Solution:1

Package named php5 or php5.6 is just a meta-package that pulls one of the available web SAPIs (apache2, fpm or cgi). The easiest way how to remove full stack of packages is to remove php5-common and/or php5.6-common package as everything else depends on it, e.g.:

apt-get purge php5-common  

The other option would be to use wildcard support in apt-get and do:

apt-get purge 'php5*'   


Solution:2

Try running apt-get autoremove. I think what you are seeing is the FastCGI Process Manager which might have been installed with the core PHP5, but not removed as part of the uninstall. Failing that apt-get remove php5.6-fpm --purge --autoremove. You are already running the v7 of fpm so shouldn't see any adverse effects.


Solution:3

You can completely remove all PHP packages with this command:

sudo apt-get purge `dpkg -l | grep php| awk '{print $2}' |tr "\n" " "`  

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »