I do not recommend this. You might notice that in the title. I also don’t know how well this will work in the long run and do not provide any sort of promises around anything written here.
That being said, there is a certain satisfaction in finally accomplishing something difficult even if doing it is probably stupid and you had to use AI to help format stupid terminal commands.
In my semi-defense, I set this Pressbooks install up on a Reclaim cPanel account 4 or 5 years ago. Reclaim support and I went through the hassle of getting it to work back then in a collaborative fashion (assuming my memory is correct). Since then, and I think sensibly, Reclaim has moved to putting Pressbooks in a Reclaim Cloud instance and not having it run in cPanel because it really is a pain in so many ways. At some point, I had big hassles when I attempted to upgrade WordPress or Pressbooks or both WP and PB . . . and so I rolled it back and let it sit for some day when I had more time.1
At some point since then, the PDF export for the Pressbooks install broke. This only became apparent because we’ve got a poetry book project that has a short timeline. So this became a priority and one I became irrationally determined to fix. I used AI to help me do this. It is something of a tangle mess in my head so I’m trying to get it in order here for future reference when things eventually break.
The basic problem is that there’s the main cPanel root(?) server stuff and then there’s the cPanel account. The mix of what can access what is something I don’t entirely understand. I’m also not entirely clear when I, as a super admin, can do certain things to that root server. I am also a bit hesitant to do that when I am doing something entirely new . . . like this.
So the goal became to set up Prince to use in Pressbooks in a cPanel sub account without asking for any server-level changes.
I think there are decent odds this is correct.
You can do it all in the little virtual terminal in cPanel if you want.
First, what OS is this? Maybe people remember this but I do not.
hostnamectl
That tells me we are running Ubuntu 20.04.6
Download the Ubuntu 20.04 version of Prince and unzip it. You can see the names for the various versions here.
cd ~ wget https://www.princexml.com/download/prince-16-ubuntu20.04-amd64.tar.gz tar -xzf prince-16-ubuntu20.04-amd64.tar.gz cd prince-16-ubuntu20.04-amd64
Run the install script interactively. Do not pass –prefix as an argument, it won’t work. Or, at least, I couldn’t get it to work and spent some time on it.
./install.sh
When prompted for an install directory, enter this.
/home/YOUR_CPANEL_USER/prince
Prince requires a few shared libraries that you probably don’t have.
ldd /home/YOUR_CPANEL_USER/prince/lib/prince/bin/prince | grep "not found"
On our server, two libraries were missing: libgif.so.7 and libwebpdemux.so.2. Download and extract them without root using apt-get download.
cd ~ apt-get download libgif7 dpkg -x libgif7*.deb ~/libgif/ apt-get download libwebpdemux2 dpkg -x libwebpdemux2*.deb ~/libwebp/
Now, because we set up stuff differently than what PressBooks is expecting we have to set some aliases/forwarding . . . something similar to that in concept (although I realize those names probably mean something really specific in server land. I think technically this is called a wrapper script.
cat > /home/YOUR_CPANEL_USER/prince-wrapper.sh << 'EOF' #!/bin/sh LD_LIBRARY_PATH=/home/YOUR_CPANEL_USER/libgif/usr/lib/x86_64-linux-gnu:/home/YOUR_CPANEL_USER/libwebp/usr/lib/x86_64-linux-gnu export LD_LIBRARY_PATH exec /home/YOUR_CPANEL_USER/prince/bin/prince "$@" EOF chmod +x /home/YOUR_CPANEL_USER/prince-wrapper.sh
Make sure that works. It should return Prince 16.
/home/YOUR_CPANEL_USER/prince-wrapper.sh --version
Now change what wp-config.php points to for Prince (assuming you already had it there). There’s other stuff PB asked you to add if I recall correctly.
define( 'PB_PRINCE_COMMAND', '/home/YOUR_CPANEL_USER/prince-wrapper.sh' );
Now that may seem simple but it took me a long time with the help of Claude. I did end up on a whole side issue for a while which didn’t help. I am not a server guy. I think I got all the pieces in order but I did not test all this on a fresh failing installation. I did not have any success with mPDF as a fall back, but my efforts there were limited.
1 I’ve got 99 problems and remember exactly what my problems are is one.a
Ah, thanks for the write-up. I don’t feel so incompetent now.
I too, had a Pressbooks install working in it’s own cPanel account on a Reclaim install. It too was really old – I think Timmy helped set it up, so that old. It stopped showing up for work some years ago and I decided to I’d “fix” it when I retired. I retired last year and just decided to nuke the whole thing a few months ago.
It took more effort than was reasonable. Congratulations on the retirement and for making sensible choices like nuking PB. You’re retired!
Just because you can, should you? 🙂
I didn’t put enough caveats in this post?