RHEL – Best Practices for Installing a Package Locally to a User

homenot-root-userrhelrpmsoftware installation

I want to install Git locally to a user on a RHEL server (I don't have root access)
What would be your cleanest/ most organized way of installing software to a local user account?

  • Installing everything in that users home directory?
  • What would the directory layout look like?
  • Would you install from source or RPM?
  • If from RPM would you use YUM or RPM?

Best Answer

There are ways to install rpms in a user directory using rpm, but I don't believe it is straight-forward. I don't believe there is a way with yum.

My standard practice has become to compile from source to a local directory in my home

$ mkdir ~/local
$ mkdir ~/local/bin
$ mkdir ~/local/lib
$ mkdir ~/local/include

I download source as I would to /usr/local when I have root, e.g., in ~/local/git.

When compiling I set the prefix to the local directory

$ configure --prefix=/home/user_name/local
$ make
$ make install

I then add ~/local/bin to my $PATH in .bash_profile.

Of course, the pain with installing from source is that you don't get automatic dependency resolution. If you find that you need to install dependencies, compile and install them as above. Then when you compile git, you need to update the compile flags so they look in the correct location for the dependency's libraries and include files:

./configure --prefix=/home/user_name/local LDFLAG='-L/home/user_name/local/lib' CFLAGS='-I/home/user_name/local/include' CPPFLAGS='-I/home/user_name/local/include' CXXFLAGS='-I/home/user_name/local/include'
Related Question