Install new programs to a shared-hosting server ( without su / root )

This information is for educational purposes only, and is not guranteed to work for all cases. Attempting the steps below might violate your hosting provider’s terms of agreement. For example, check out this excerpt from Godaddy’s legal hosting agreement.
Proceed at your own risk! 😀

Before we begin
Many website hosting companies prevent their customers from installing new software to shared-hosting servers. They restrict use of the GCC(Gnu Compiler Collection) tools, because the GCC can be used to build executable programs from source code. Although this is great for the hosting company’s security and server performance, it’s a less than ideal situation for any website owner to be forced to use out-of-date versions of software. Below, I’ve outlined a work-around around which helped me get around a big-name hosting provider’s GCC usage restriction. For any website owners seeking flexibility, Virtual Private Server(VPS) or Cloud hosted instance are both a much better option than shared-hosting.

Discover installed software

Install Libraries & Create Folders

Download Install GNU C compiler

Discover current configuration and installed software ( type and version)
Before trying to download or install anything, it helps to know what kind of system the hosted server is running on. Do this with uname -a The system I used for this example was running Linux Kernel version 3.10 and seemed to be a CentOS based distribution. First thing I did was to check for already installed package-manager. The two major ones are .deb(Debian distros ) and .rpm. (Red Hat distros ) Use “which” command to find out which version your server uses. I checked for a Debian package manager with:
which dpkg

Check for Red Hat package manager.
which rpm


Rpm is installed

I’ll be using the rpm(RedHat Package Manager) in this guide, but the process should be be similar for a different package manager.

Install Libraries & Create Folders
In your home directory, create source folder to hold extracted files and another for the binary files. cd ~
mkdir ~/src
mkdir ~/bin
Add the ~/bin directory to your executables PATH. code>export PATH=~/bin:$PATH

Download Install the GNU C compiler
Now we need to download GCC which will compile the programs. Before doing this, check the system for the currently installed version. If you do not have execute permission for the compiler in /bin/gcc, then running gcc --version will not work. Instead query the package manager on your server to find out which version of gcc is installed. That command for me was:

rpm -qa | grep gcc

Take note of the version number and then hop over to Pkgs.org to find a gnu package which matches the version from the command above. Now we need to extract the files from the gcc package to a directory of our choice. This next step differs slightly for each package manager. For rpm, I found the following guide to be a great help: https://blog.packagecloud.io/eng/2015/10/13/inspect-extract-contents-rpm-packages/ We need to extract all files from the package but maintain directory structure as if a super user unpacked them. This command does just that for rpm packages: rpm2cpio gcc-4.4.7-23.el6.x86_64.rpm | cpio -i --no-absolute-filenames -d -m -v
Flags used with cpio:
-d --make-directories
-m --preserve-modification-time
-v --verbose
After unpacking, find the gcc binary in the “bin” directory, and add it to your PATH using: ln -s ~/path/to/gnu/compiler/bin/gcc ~/bin
At this point I tried to compile one of my favorite programs, tree , and was met with yet another error message: "ld not available"
The man page for ld describes ld: “… ld combines a number of object and archive files, relocates their data and ties up symbol references. Usually the last step in compiling a program is to run ld…” Ld is one of the tools contained within the binutils package, so the next step is to install binutils that and hope there are no more major hurdles to clear.

Install binutils
To find the version of binutils compatible with the server, run

Binutils version check
rpm -qa | grep binutils

Take note of the version value and try to find the exact version on the GNU software website. The New York-based RIT server has a ton of download packages and mirrors and worked great for me. After downloading the package, extract the files, find and run the .configure script to build ld. Next, add ld to your path ln -s ~/path/to/binutils/bin/ld ~/bin

Install new programs!
If you made it this far, you should be able to install programs on the server. I usually search for a pre-compiled binary on Pkgs.org before I try compiling from source. Expect to receive the odd error message here and there, for a missing library, or from install scripts trying to save files in location without write permissions. Remember to create a link for each newly compiled binary eg. "ln -s ~/path/to/binary/directory/binary-file"
, and place the link inside your home binary folder( eg. ~/bin )

Other Guides
If you were unable to find a compatible gcc binary, you might have success grabbing the binaries from a virtual machine with a distro similar to that of your server. This virutal machine would ideally have the same kernel version and cpu architecture as your server. Here’s another guide to achieve the same result using a different methods: https://ericdraken.com/transplanting-linux-shared-dynamic-libraries-shared-hosting/

Abusive Activities and Other Threats. You acknowledge and agree that you may not use our servers and your website as a source, intermediary, reply to address, or destination address for mail bombs, Internet packet flooding, packet corruption, denial of service, or other abusive activities that threaten the stability of our network or will damage the systems of, or cause a disruption of internet services to, GoDaddy, our customers, or third-parties. Server hacking or other perpetration of security breaches is prohibited and we reserve the right to remove sites containing information about hacking or links to such information. Use of your website as an anonymous gateway is prohibited. We prohibit the use of software or scripts run on our servers that cause the server to load beyond a reasonable level, as determined by us. You agree that we reserve the right to remove your website temporarily or permanently from our servers if you are in violation of this Service Agreement and/or there are activities that threaten the stability of our network. You acknowledge and agree that all websites associated with your hosting account may be removed if one website is in violation of this Service Agreement. You further acknowledge and agree that GoDaddy reserves the right to scan your hosted account for malicious content (e.g., malware), and that, in the event any such content is discovered, it may be removed in GoDaddy’s discretion for security purposes.
Godaddy.com