From https://unix.stackexchange.com/questions/42567/how-to-install-program-locally-without-sudo-privileges
Compile and install into ~/bin (and edit your .bashrc to set the PATH to include it). libraries can similarly be compiled and installed into ~/lib (set LD_LIBRARY_PATH to point to it), and development headers can be installed into e.g. ~/includes.