How do you generally proceed for your package installations on Linux, for packages that are not part of your distrib's repos?

On my side I am used to install in /opt. But since, I saw this doc on the Internet: . Now I am confused: apparently /usr/local would be also a possibility.

What is the difference between both? Any best practices to share?

Thanks

SirFabel

2

7 Answers

  • Everything that has to be compiled & installed Unix-style and complies to FHS -> /usr/local
  • Everything else (e.g. a java web-application that comes with it's own applicationserver and loads of resources in a zip archive -> /opt
0

Just as additional interesting info: The original meaning of /usr/local is that if /usr is network-mounted (single /usr shared across multiple computers), /usr/local would be a separate filesystem local to the computer (partition on local disk).

And while on that topic, even if it's off-topic to the question: If there are multiple computers with different architectures, naturally there would be one /usr for each arch, but /usr/share would be yet another separate filesystem shared between architectures (hence 'share').

6

The way I do it is that if it requires a prefix to itself OR it's a binary package, I go for /opt (which is pretty much the Solaris way). If i'm compiling from source /usr/local is how I go.

I put everything in a private directory and then use GNU stow.

So, I'll install package X.ver to /BASE/stow/X.ver. GNU stow will then combine all the packages (with symlinks) into /BASE/bin, /BASE/lib, etc.

Conflicts and removing packages are much easier to deal with.

1

Here is how I do interpret the FHS standard:

/usr/local is for locally built or locally installed files, whether packaged or not that somewhat become part of that instance of the Operating System.

/opt is a place to install "foreign" packages not part of the Operating System.

As long as you only use files on the single system where you build them, /usr/local is fine, and it is therefore the default base directory for the vast majority of open source software.

If you plan to redistribute your package, I would recommend using a custom base directory like /opt/myPackage.

Solaris used /opt a lot. Many modern Linux distros now expect packages in /usr/local/. The idea is the same - a place to put software that makes this machine do what it does, as opposed to the operating system. It's roughly analogous to "Program Files" on a Windows system.

Pick one and stick to it. It's easy enough to symlink /opt to /usr/local.

2

If you recompile a software provided by your operating system distribution, to leverage several architecture advantages specific to your very own machine, use /usr/local.

If you add a piece of software from other sources, than your operating system distribution, put it into /opt.

0

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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