谷歌就有,不过还是烦了一段时间,新手,好多东西都不懂
2.安装libwkhtmltox
- mkdir libwkhtmltox
- cd libwkhtmltox
- wget http://wkhtmltopdf.googlecode.com/files/libwkhtmltox-0.10.0_rc2-amd64.tar.bz2
- tar xjvf libwkhtmltox-0.10.0_rc2-amd64.tar.bz2
- cp -v lib/libwkhtmltox.so /usr/local/lib
- cp -Rv include/wkhtmltox/ /usr/local/include
- cd /opt/app/php5-fastcgi/bin
- wget https://codeload.github.com/mreiferson/php-wkhtmltox/zip/3309e6e0cafd60a772e3f32741b144f89f6993da
- unzip php-wkhtmltox-master.zip
- cd php-wkhtmltox-master
- ../phpize
- ./configure
在./configure的时候仔细找下看又错误没,我这边提示有两个问题,
一个是 checking for re2c... no
configure: WARNING: You will need re2c 0.9.11 or later if you want to regenerate PHP parse
这个好解决,安装下re2c就ok了,另外一个比较麻烦configure: error: libwkhtmltox version 0.10 or later required
./configure --with-php-config=‘PHP安装目录下’/bin/php-config CFLAGS='-L/usr/local/lib' LDFLAGS='-L/usr/local/lib'
,不行,需要安装fontconfig才可以
- wget http://fontconfig.org/release/fontconfig-2.4.2.tar.gz
- tar xzvf fontconfig-2.4.2.tar.gz
- cd fontconfig-2.4.2
- ./configure
- make
- make install
- vim /etc/ld.so.conf
- //添加一行
- /usr/local/lib
- ldconfig
- //如上问题解决以后重新编译
- ./configure --with-php-config=‘PHP安装目录下’/bin/php-config CFLAGS='-L/usr/local/lib' LDFLAGS='-L/usr/local/lib'
- make
- make install
- vim 'php目录'/php.ini
- //添加一行
- //extension="phpwkhtmltox.so"
- 'php目录'/sbin/php-fpm reload
- php -m | grep phpwkhtmltox
- //有返回表示已经成功安装了
1.5.1.编辑测试的php脚本test_html_to_image.php
<?php wkhtmltox_convert( 'image', array( 'out' => '/tmp/test.jpg', 'in' => 'http://www.baidu.com' ) ); ?>
- //中文显示问题,运行如下命令解决
- yum groupinstall chinese-support
转载地址:http://blog.chinaunix.net/uid-17291169-id-3804348.html