I want to purge PHP completely from my Ubuntu 16.04. I have did all the stuff to remove PHP which as below,

sudo apt-get purge "php*"
sudo apt-get purge "^php.*"
sudo apt-get purge "^php*"
sudo apt-get remove "php*"
sudo aptitude remove ~iphp
sudo aptitude search "~iphp"
rm -rf /etc/php/

Although when I check from the terminal and run php -v it still shows the PHP 5.4.15 (cli).

Does have any idea about this?

  • Can you share the output of dpkg --list | grep php? – Mr Shunz Sep 21 '18 at 9:32
  • Hi Shunz It gives me nothing. – Emipro Technologies Pvt. Ltd. Sep 21 '18 at 9:35
  • Maybe it was not installed via package manager? Try which php and whereis php to show the full path of the php binary. – Mr Shunz Sep 21 '18 at 9:39
  • which php shows "/usr/local/bin/php" whereis php shows "php: /usr/local/bin/php /usr/local/lib/php /usr/local/php" – Emipro Technologies Pvt. Ltd. Sep 21 '18 at 9:45

From your comments, looks like php was installed either via source code or with some kind of binary distribution, but not via apt/dpkg.

To uninstall it, you should first know how it was installed!

Usually, if via source code, you should find a directory under /usr/src or /usr/local/src (or your home, or...) containing the said source code (maybe /usr/src/php-X.Y.Z).

Then it (usually!) will be enough to use make uninstall, but you should check the source code documentation for the proper procedure.

If it was installed via a binary distribution, there might be an uninstall command (try looking in /usr/local/bin) or you should proceed to manually delete every file/directory.

If you didn't install php yourself, you should ask who installed it which method was used and acting accordingly.

EDIT as per comments

Looks like you installed it via source code, so to uninstall it you can try

cd php-5.4.15
make uninstall
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.