Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

When compiling programs, should they be given their own --prefix (eg /usr/local/php5/) to keep all the files for that program separate, or just installed in the default location (eg /usr/local/)

It seems to me that installing with a prefix is better, since it makes uninstalling easy. If this is the case, why do programs not default to a custom install location?

What are the pros and cons of a custom --prefix?

share|improve this question
4  
According to the Filesystem Hierarchy Standard if you want each program to have its own directory, then you should use the /opt prefix, not /usr. Quoting from the documentation: "A package to be installed in /opt must locate its static files in a separate /opt/<package> [...] Programs to be invoked by users must be located in the directory /opt/<package>/bin [...]. If the package includes UNIX manual pages, they must be located in /opt/<package>/share/man [...].". –  Cristian Ciupitu Jun 13 '12 at 17:17

1 Answer 1

When you type "php" in the shell, the shell first looks up the PATH variable ("echo $PATH"), and goes dir-by-dir to find that "php" binary to run. paths like "/bin", "/usr/bin", etc. are there. Paths like "/usr/local/php5/bin" are not (unless you add them yourself).

In nix, it is a standard to put binaries into "/bin" folders, configs to "/etc", etc., and everybody expects them to be there (so if you have a script which calls php, you'll have a problem if it's not in a "standard" folder.

Uninstalling is never a problem if you use a package manager, since it keeps track of all files installed, and it can uninstall them. If you use a debian/slackware/redhat based distribution, check out "checkinstall", which allows you to create packages from your compiled code, which you can then easily uninstall when needed

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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