This question already has an answer here:

How can you uninstall software that was built and installed from source? (Using make install?)

marked as duplicate by jasonwryan, Anthon, slm, Mat, George M Jun 20 '13 at 14:33

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

migrated from serverfault.com Jun 20 '13 at 7:47

This question came from our site for system and network administrators.

  • The easy way would be to compile PHP 5.5 and install it over 5.4. The RPM likely installs to a different folder. – Nathan C Jun 19 '13 at 19:12
  • If you haven't already deleted the directory where you built from source, and if you let make install choose the target directory, it might have ended up in /usr/local/bin, which usually has precedence over /usr/bin, hence you still use the first php binary found in your PATH. You could try make -n install and see where and what it wants to install stuff, and remove by hand. Untested and dangerous, of course. – dawud Jun 19 '13 at 19:14
  • @dawud Yes, i actually ended up doing it this way. I was just wondering if for future reference there might be a better, safer way – Quinma Jun 19 '13 at 19:16
  • 1
    If the Makefile provides the means, then yes. Always generate packages, even for upstream built sources. – dawud Jun 19 '13 at 19:18
  • 1
    OP, I blew away your question as it was asked to make it trigger less votes to close. It was a legitimate question masked behind a lot of extra words.. – Aaron Copley Jun 19 '13 at 19:28

Do you still have the source package? You can parse the Makefile for install commands, or you can install it again (with another $PREFIX) to capture a list of installed files. Also, it is printed to STDOUT. You could then remove those files from the directory where they were installed originally.


I just dug up my notes on making an uninstaller script. Bear with me, I am paraphrasing here.

After you build and install to a temporary target directory, do the following. (Where $PREFIX is whatever you used with ./configure.)

find . -type f | cut -b 1 --complement | sed 's/^/rm -f \/usr\/local/g' > uninstall.sh
find . -type d | cut -b 1 --complement | sed 's/^/rmdir --ignore-fail-on-non-empty \/usr\/local/g' >> uninstall.sh

The output will look like:

rm -f /usr/local/lib/somelib.so
rm -f /usr/local/bin/somebin
rm -f /usr/local/include/someapp/someheaders.h
rmdir --ignore-fail-on-non-empty /usr/local/share
rmdir --ignore-fail-on-non-empty /usr/local/bin
rmdir --ignore-fail-on-non-empty /usr/local/include/someapp

This doesn't actually remove the critical system directories (/usr/local/bin, etc) because they'll be non-empty. Also, you'll want to confirm that your ./configure script uses /usr/local as the default $PREFIX. Adjust the sed command as necessary.

  • Damn Linux. I really should start using a different prefix for each program isntead of /usr/local – mxmlnkn Sep 27 '17 at 2:10

I checked with php version 5.4.16

cd php-5.4.16

make clean
make clean all

find / -name php

rm -fr /usr/local/php /usr/local/lib/php /usr/local/bin/php /usr/local/include/php

whereis {php-config,phpize,php-cgi}
rm /usr/local/bin/php-config /usr/local/bin/phpize /usr/local/bin/php-cgi

whereis {pear,peardev}
rm /usr/local/bin/pear

rm /usr/local/bin/peardev

why I select phpize and php-config
because after ./configure I got this output

config.status: creating php5.spec
config.status: creating main/build-defs.h
config.status: creating scripts/phpize
config.status: creating scripts/man1/phpize.1
config.status: creating scripts/php-config
config.status: creating scripts/man1/php-config.1
config.status: creating sapi/cli/php.1
config.status: creating main/php_config.h


You could try to brute force it:

Do a find / > /tmp/all_files and save to a file all_files. (Exclude sysfs and procfs and other if you know the files are not there)

Do a rpm -qa | xargs rpm -al > /tmp/all_owned_files to get a list of all files "owned" by rpm. (Assuming this is a rpm based system, use other commands for non-rpm systems)

Do a diff between these two files, and comb through it.


check the command in source directory

make clean

make clean all

Or you have to remove all the files as described by Aaron

  • 1
    make clean very rarely, in my experience, removes the installed binaries; it only cleans out compilation-related cruft from the build directory. – MadHatter Jun 19 '13 at 19:25
  • 1
    make clean in fact does not removed installed files. It simply removes things like object files (.o) so they can be re-compiled (say, if the configure or Makefile is changed). – Nathan C Jun 19 '13 at 19:38
  • I am just downloading the php source code to check what steps should be followed. – Sharad Chhetri Jun 19 '13 at 19:40

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