I have an account with bluehost that gives me ssh access, but no sudo, so I cannot use yum (it’s a CentOS server).
I want to run a script that depends on phantomjs, but it fails, apparently because I do not have access to freetype and fontconfig. Contacting them, they’ve told me
Sounds like we have both of the font libraries needed, but because this is not a software we provide for you, support for it is limited.
When asking if there was no way to do it, they replied with
It might be possible, but we won't provide any support for it or set it up for you.
So my question is how can I install those libraries independently (preferably already compiled/ready), and make phantomjs use them?
One possibility is to load the auxiliary libraries that you need into a “private” location, and then alter the headers of your program to search that location.
Mimic your target environment
cat /etc/*-releaseshould give you the one piece of information;uname -awill give you the other. Specifically, you want to ensure that you have a similar/same C library version;/lib/libc.so.?should be executable and give you some details about the C library in use.)Figure out what the target environment is missing
Run
ldd /usr/bin/your-appto obtain the list of libraries to which it refers. Specifically, to clean up that list: ldd /usr/bin/your-app | cut -d '(' -f 1 | cut -d '>' -f 2 | sed -e 's,[ \t],,g' | sort | uniq > my-required-libsLog in to the remote server and copy the file over; then run something like:
#!/bin/sh
Copy
missing-libsback to your virtual host andmkdira folder named e.g.~/my-app/lib; thencp $(<missing-libs) /home/myself/my-app/libNOTE, that you will need to create this exact path on your shared host, including the user name and so forth — so if your writable directory on the shared host is
/home/myselfmake sure that this directory is under/home/myselfon the virtual host as well.Alter the executable's RPATH to point to your alternate library location
Find your application executable file and alter its headers using
chrpath(you will probably need toyum install chrpathin your virtual machine, as this is an unusual program to need):chrpath --list /usr/bin/your-app
If that reports any existing RPATH, then you'll want to PREPEND the path ~/my-app/lib to that RPATH with a
:— e.g. ifchrpath --listshowed/usr/lib/my-app/pluginsyou might use/home/myself/my-app/lib:/usr/lib/my-app/plugins. In the more usual case, just use--replacewith the name of the directory into which you've copied the prerequisite libraries.chrpath --replace ~/my-app/lib /usr/bin/your-app
Now, copy the executable with the new RPATH and the directory full of supporting libraries to your shared host.
This is all “friendly” to a multi-user shared-hosting set-up, unlike other solutions using e.g.
chrootjails.Alternatively, create an LD_LIBRARY_PATH wrapper
If
chrpathdoesn't work for your set-up (e.g. extremely strict SELinux contexts), you may be able to skip thechrpathstep and instead do something like:and make a wrapper script like
… and replace the original binary's name with this script.
Note, in theory, you can replace almost any library this way, but when libraries require data files in particular places (e.g.
/etc) or dynamically invoke sub-libraries from system locations (e.g./usr/lib64), you may be faced with having to recompile them with new paths in their./configurescripts or editing their sources in ways that are probably not worth the effort in all but the most extreme cases.EG: Things that are unfriendly to relocating in this way:
libcand Pluggable Authentication Modules.