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 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 -aThe 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:
Rpm is installed
Install Libraries & Create FoldersIn your home directory, create source folder to hold extracted files and another for the binary files.
mkdir ~/binAdd the ~/bin directory to your executables PATH. code>export PATH=~/bin:$PATH
Download Install the GNU C compilerNow 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 --versionwill 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
rpm2cpio gcc-4.4.7-23.el6.x86_64.rpm | cpio -i --no-absolute-filenames -d -m -vFlags used with cpio:
-v --verboseAfter unpacking, find the gcc binary in the “bin” directory, and add it to your PATH using:
ln -s ~/path/to/gnu/compiler/bin/gcc ~/binAt 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 binutilsTo find the version of binutils compatible with the server, run
rpm -qa | grep binutils
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 GuidesIf 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.
When I first started using Mysql, I relied heavily on the Phpmyadmin in-browser control panel for database administration. Eventually the feeling of reliance on the GUI became became so unbearable that I switched to using the command line mysql client to communicate with the database server. Here is how I use the the Mysql cli with Vim to accomplish tasks such as user creation, and search-replace operations.
Why use the Mysql cliUsing the command line interface offers offers several benefits. Visually there are less distractions when compared with. I find that I pay much more attention to each keypress and am inclined to pay attention to every character of output the cli displays. The cli experience is also snappier being ‘closer’ to the databse, and feels more interactive. Though I don’t mind using Phpmyadmin, it always feels good to eliminate a possible point-of-failure, even with such ubiquitous tool where bugs are unlikely. Update 9/18/19: A few months ago when I wrote this post, I thought this might be a stretch to suggest, but it looks like increased security is indeed a legitimate reason to choose the CLI. Check out this article on LinuxSecurity.com:
MySql Vi ConfigTo set the mysql pager to vim( or less, nano etc.) Simply enter the following command (including the minus sign ):
\P vi -
Vim will open each query result in a temporary file which you can then navigate/search/edit like any other text file. It is also possible to use the \e flag to enter editing mode and then use vim to structure your query before executing it.
pager (\P) Set PAGER [to_pager]. Print the query results via PAGER.
I use the “HELP” query to obtain the proper syntax of unfamiliar commands. It’s usually quicker than switching tabs to search the online documentation. It’s also great to have the results in vim so that the text can be quickly manipulated in-place to form the next query. To view the same results using Phpmyadmin, I had to select the “Full texts” option under “Options”. PhpMyAdmin is a great choice for those uninterested in becoming comfortable on the command line. However, for the rest of us, choosing to use the cli version will eventually lead to more efficient database use. Also vim users enjoy the added benefit of stacking skills by using vim as the primary pager. It’s a great way to maintain the familiarity with the editor’s options and abilities, which comes only from frequent use.
edit (\e) Edit command with $EDITOR.