4

I installed PHP by following this answer on 14.04:

sudo -i
wget http://in1.php.net/distributions/php-5.3.29.tar.bz2
tar -xvf php-5.3.29.tar.bz2
cd php-5.3.29
./configure
make
make install

I want to uninstall this now and also make sure there are no other versions installed (packaged or otherwise) and if there are, remove them too. How can I do this?

  • 2
    Sorry, which version do you want to uninstall? The one you built yourself or one installed by package management? – Oli Jan 5 '15 at 9:44
12

Packaged PHP installations can be removed fairly easily by removing the php5* packages. To be thorough, we'll target any packages that start php:

sudo apt-get remove '^php'

To uninstall something you installed from source, you would traditionally cd back into the directory you built it from and run sudo make uninstall but in this case it seems that PHP doesn't ship a removal target for make.

That makes removing it incredibly hard. You can either manually find all the files it installed, or you can (maybe) build a real package from the existing compiled version you have, install that over the existing files and then remove it.

sudo apt-get install checkinstall
sudo -i
cd php-5.3.29
checkinstall

Accept all the defaults. By the end of it, it should have built and installed a php package (check the package name as checkinstall tells you) and then you can remove it with:

sudo apt-get remove php  # or whatever the actual package was called

If checkinstall doesn't work (it doesn't always), you're left hunting for files. Stalking through the Makefile and commands like locate php might help but with something as vast as PHP, it's going to be a long process. If you need a quick recovery, a reinstall (or backup restore, because you have those, right?) might be a better option.


As for verification, I'd just try running php5 in a command line. whereis php5 might be illuminating too. If they're returning results, you probably have more work to do.

  • you should make a note that this works, but it won't work unless you build the tarball as a package here - whereas the plain source tarball installed version can't be easily removed without that step, which seems to be swift's failing point in their answer below. – Thomas Ward Jan 7 '15 at 12:54
  • you can also use "whereis php" to locate php, it's a very handy command indeed. – iCurious Jun 30 '15 at 9:04

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.