Wkhtmltox Project home: http://wkhtmltopdf.org/supports HTML to PDF, image
PHP extension Php-wkhtmltox Project home: Https://github.com/mreiferson/php-wkhtmltox
1. Download and install Wkhtmltox system environment
http://wkhtmltopdf.org/downloads.html Download Wkhtmltox According to the system type selection:
Here my system environment is CentOS 6-64bit so choose: Linux CentOS 6-64bit
After downloading it is a RPM package [wkhtmltox-0.12.2_linux-centos6-amd64.rpm].
Install Wkhtmltox:
> RPM-IVH wkhtmltox-0.12.2_linux-centos6-amd64.rpm
error:failed dependencies:
XORG-X11-FONTS-75DPI is needed by wkhtmltox-1:0.12.2-1.x86_64
# Prompt to install 75dpi
> Yum Search 75dpi
Loaded Plugins:fastestmirror, Refresh-packagekit, security
Loading mirror speeds from cached hostfile
* base:centos.ustc.edu.cn
* extras:centos.ustc.edu.cn
* updates:centos.ustc.edu.cn
============================================================ N/S matched:75dpi ================================== ==========================
Xorg-x11-fonts-75dpi.noarch:a set of 75DPI resolution fonts for the X Window System.
Xorg-x11-fonts-iso8859-1-75dpi.noarch:a set of 75dpi iso-8859-1 fonts for X.
xorg-x11-fonts-iso8859-14-75dpi.noarch:iso8859-14-75dpi fonts
xorg-x11-fonts-iso8859-15-75dpi.noarch:iso8859-15-75dpi fonts
Xorg-x11-fonts-iso8859-2-75dpi.noarch:a set of 75dpi Central European language fonts for X.
xorg-x11-fonts-iso8859-9-75dpi.noarch:iso8859-9-75dpi fonts
Name and summary matches only, use ' Search all ' for everything.
> Yum Install Xorg-x11-fonts-75dpi.noarch
After the installation is complete, perform the following:
> RPM-IVH wkhtmltox-0.12.2_linux-centos6-amd64.rpm
installed, under execution: wkhtmltopdf http://www.baidu.com baidu.pdf can be a description of success.
If you cannot install Xorg-x11-fonts-75dpi.noarch
Use the following methods to extract the packages that have been compiled in the RPM package directly:
> Rpm2cpio wkhtmltox-0.12.2_linux-centos6-amd64.rpm | Cpio-div
After completion in the current directory will generate a USR directory containing local/bin,local/include,local/share,local/lib four folders
Copy the contents of the corresponding folder to/usr/local!
> cp-rv./usr/local/*/usr/local/
Wkhtmltox System Environment installation is complete!
2. Install Php-wkhtmltox Extension
Https://github.com/mreiferson/php-wkhtmltox
Download the source bundle on GitHub [Php-wkhtmltox_master.zip]
> Unzip Php-wkhtmltox_master.zip
> CD Phpwkhtmltox
> phpize
There will be no phpize found here.
Download a package for this Yum provides phpize follow the prompts to install the package. Yum Install Php-devel
>./configure--with-php-config=/usr/local/php/bin/php-config #此处按照各自系统php安装路径不同而定
> Make && make Install
> Ldconfig # Reload system dynamic link library
> php-m
# Check if the extension is successful if you can see the Phpwkhtmltox description extension succeeded
Php-wkhtmltox extension installation is complete.
3. Modify the php.ini file to open the extension
> Vi/usr/local/php/etc/php.ini
Join:
extension= "Phpwkhtmltox.so"
>/etc/init.d/php-fpm Restart
Installation is complete!
This article is from the Linux Security Advisor blog, so be sure to keep this source http://chengyangyang.blog.51cto.com/9473151/1675419
RPM Installation Wkhtmltox system environment