Linux環境下php實現給網站截圖的方法_php技巧

來源:互聯網
上載者:User

本文執行個體講述了Linux環境下php實現給網站截圖的方法。分享給大家供大家參考,具體如下:

第一步:下載wkhtmltopdf

複製代碼 代碼如下:
[root@iZ94aawoublZ ~]# wget http://download.gna.org/wkhtmltopdf/0.12/0.12.3/wkhtmltox-0.12.3_linux-generic-amd64.tar.xz

第二步:解壓

複製代碼 代碼如下:
[root@iZ94aawoublZ ~]# xz -d wkhtmltox-0.12.3_linux-generic-amd64.tar.xz

第三步:繼續解壓

複製代碼 代碼如下:
[root@iZ94aawoublZ ~]# tar xvf wkhtmltox-0.12.3_linux-generic-amd64.tar

第四步:選擇目錄

複製代碼 代碼如下:
[root@iZ94aawoublZ ~]# cd wkhtmltox
[root@iZ94aawoublZ wkhtmltox]# ls
bin  include  lib  share

第五步:選擇lib目錄

複製代碼 代碼如下:
[root@iZ94aawoublZ wkhtmltox]# cd lib/
[root@iZ94aawoublZ lib]# ls
libwkhtmltox.so  libwkhtmltox.so.0  libwkhtmltox.so.0.12  libwkhtmltox.so.0.12.3

第六步:複製libwkhtmltox.so到usr/local/lib

複製代碼 代碼如下:
[root@iZ94aawoublZ lib]# cp libwkhtmltox.so /usr/local/lib
[root@iZ94aawoublZ lib]# cd ../include/

第七步

複製代碼 代碼如下:
[root@iZ94aawoublZ include]# cp -R wkhtmltox/ /usr/local/include/

第八步:安裝php wkhtmltox

複製代碼 代碼如下:
[root@iZ94aawoublZ include]# wget https://github.com/mreiferson/php-wkhtmltox/archive/master.zip
[root@iZ94aawoublZ include]# ls
master.zip  wkhtmltox

第九步:解壓

複製代碼 代碼如下:
[root@iZ94aawoublZ include]# unzip master.zip

第十步:選擇目錄

複製代碼 代碼如下:
[root@iZ94aawoublZ include]# cd php-wkhtmltox-master/

第十一步

複製代碼 代碼如下:
[root@iZ94aawoublZ php-wkhtmltox-master]# /usr/local/php/bin/phpize
Configuring for:
PHP Api Version:         20131106
Zend Module Api No:      20131226
Zend Extension Api No:   220131226

第十二步:安裝

複製代碼 代碼如下:
[root@iZ94aawoublZ php-wkhtmltox-master]# ./configure --with-php-config=/usr/local/php/bin/php-config
[root@iZ94aawoublZ php-wkhtmltox-master]# make
[root@iZ94aawoublZ php-wkhtmltox-master]# make install
Installing shared extensions:     /usr/local/php/lib/php/extensions/no-debug-non-zts-20131226/

第十三步

複製代碼 代碼如下:
[root@iZ94aawoublZ php-wkhtmltox-master]# echo "extension=phpwkhtmltox.so" >> /usr/local/php/etc/php.ini
[root@iZ94aawoublZ php-wkhtmltox-master]# service php-fpm restart
Gracefully shutting down php-fpm . done

測試有沒有成功

小試牛刀:

<?phpwkhtmltox_convert(  'image',  array(    'out' => 'test1.jpg',    'in' => 'http://www.163.com/'  ));?>

更多關於PHP相關內容感興趣的讀者可查看本站專題:《PHP圖形與圖片操作技巧匯總》、《php操作office文檔技巧總結(包括word,excel,access,ppt)》、《php日期與時間用法總結》、《php物件導向程式設計入門教程》、《php字串(string)用法總結》、《php+mysql資料庫操作入門教程》及《php常見資料庫操作技巧匯總》

希望本文所述對大家PHP程式設計有所協助。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.