编译安装php扩展imagick

时间:2021-11-23 10:09:44

环境说明

CentOS 6.8、Nginx、Mysql、PHP5.5.22
php安装目录:/usr/local/php
php.ini配置文件路径:/usr/local/php/etc/php.ini
Nginx安装目录:/usr/local/nginx

安装编译器

yum -y install make cmake gcc gcc-c++ gcc-g77 flex bison file libtool libtool-libs autoconf kernel-devel patch wget libjpeg libjpeg-devel libpng libpng-devel libpng10 libpng10-devel gd gd-devel libxml2 libxml2-devel zlib zlib-devel glib2 glib2-devel unzip tar bzip2 bzip2-devel libevent libevent-devel ncurses ncurses-devel curl curl-devel libcurl libcurl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel vim-minimal gettext gettext-devel ncurses-devel gmp-devel pspell-devel unzip libcap diffutils ca-certificates net-tools libc-client-devel psmisc libXpm-devel git-core c-ares-devel libicu-devel libxslt libxslt-devel

安装扩展

1、安装ImageMagick

cd /usr/local/src  #进入软件包存放目录
wget http://www.imagemagick.org/download/ImageMagick.tar.gz #下载ImageMagick
tar -zxvf ImageMagick.tar.gz #解压
cd ImageMagick-7.0.5-5 #进入安装目录
./configure --with-php-config=/usr/local/php/bin/php-config --with-imagick=/usr/local/imagemagick #配置
make #编译
make install #安装
export PKG_CONFIG_PATH=/usr/local/imagemagick/lib/pkgconfig/ #设置环境变量

2、安装Imagick

cd /usr/local/src
wget http://pecl.php.net/get/imagick-3.4.3.tgz #下载imagick: http://pecl.php.net/package/imagick,选择一最新稳定版本stable
tar -zxvf imagick-3.4.3.tgz
cd imagick-3.4.3
/usr/local/php/bin/phpize #用phpize生成configure配置文件
./configure --with-php-config=/usr/local/php/bin/php-config --with-imagick=/usr/local/imagemagick #配置
make #编译
make install #安装

3、配置php支持imagick

注意:在安装完成后,都会在/usr/local/php/lib/php/extensions/no-debug-non-zts-20131226/ 目录下生成.so文件

vim /usr/local/php/etc/php.ini  #编辑配置文件,在最后一行添加以下内容
extension="imagick.so"

service nginx restart
kill -SIGINT `cat /usr/local/php/var/run/php-fpm.pid` #关闭php-fpm
/usr/local/php/sbin/php-fpm #启动php-fpm

测试通过

编译安装php扩展imagick

参考

http://blog.csdn.net/sxhong/article/details/42201265