PHP – How do I install wkhtmltopdf 0.12.0 and later on a Linux-based web server?

How do I install wkhtmltopdf 0.12.0 and later on a Linux-based web server?… here is a solution to the problem.

How do I install wkhtmltopdf 0.12.0 and later on a Linux-based web server?

wkhtmltopdf 0.11.0 and earlier installs just copy linux static binary file to the web server here https://stackoverflow.com/a/3116571/2464199

Then run it via PHP commands

exec('/path/to/wkhtmltopdf-amd64 file.html file.php');

There are no static binaries in newer versions of wkhtmltopdf (0.12.0 and later).

How do I install it on a shared hosting account without root access now?

Operating system on network server:

Linux multidomain1.hostsila.com 2.6.18-274.el5 #1 SMP Fri Jul 22 04:43:29 EDT 2011 x86_64 x86_64 x86_64 GNU/Linux

Linux version 2.6.18-274.el5 ([email protected]) (gcc version 4.1.2 20080704 (Red Hat 4.1.2-50)) #1 SMP Fri Jul 22 04:43:29 EDT 2011

CentOS release 5.10 (Final)

Solution

If you see the official binaries for 0.12.1, they are actually RPMs. If you do not have root access on the server, you can simply run the following command to extract the RPM contents:

rpm2cpio wkhtmltox-0.12.1_linux-centos5-amd64.rpm | cpio -idmv

You should get the binaries in the usr/local/bin subfolder, and then you can copy them wherever you want.

Note that if the dependencies (fontconfig freetype libpng zlib libjpeg openssl libX11 libXext libXrender libstdc++ glibc) are not already installed, you may need to have the host install them.

Related Problems and Solutions