centos 6.5 下imagick扩展,怎么安装

centos 6.5 下imagick扩展,怎么安装




Guide to Building an Apache/PHP/Imagick Server with Linux/CentOS 6.4:::
  1. Install CentOS 6.4. (Theoretically, other versions of CentOS should work as well, but I simply chose the most recent one.) Also, you can very easily emulate CentOS within Windows (for instance, the unfree choice of VMWare).
  2. Install PHP, PHP-Common, PHP-extensions, etc., from standard Application Package Manager ("Add/Remove Programs", usually in system tools somewhere). (You don't have to worry about Apache, because that comes with CentOS 6.4 anyway.)
  3. Open up a terminal and enter admin mode with the command "su". You'll need a password for this.
  4. Enter this command: yum install ImageMagick ImageMagick-devel
  5. Enter this command: pecl install imagick
  6. Modify php.ini and include the line "extension=imagick.so". This file is located at "/etc/php.ini" normally. The line must be exactly inserted in the section of "Dynamic Extensions", which begins with this commented out text:

; Dynamic Extensions ;

Use the "search" feature of gedit to find the text. Add the extension below the commented out note in this section so that the result looks like:

; Note: packaged extension modules are now loaded via the .ini files
; found in the directory /etc/php.d; these are loaded by default.


Putting the extension directly at the top caused me serious permission issues in running Imagick code. Also, with CentOS, the permissions automatically disable user control for this php.ini. Enter the following terminal command: "chown [YOUR-USERNAME] -R /etc/php.ini", without the quotes to get control to modify it. Note to insert your username where it states "[YOUR-USERNAME]".
7. Enter this command: "service httpd restart", without quotes, from admin mode. This restarts Apache/PHP/PHP's extensios now that you've installed ImageMagick. If this gives you an error, just try "service httpd start".

My favorite part about this method is that you can update your system with issuing the "yum update" command and then the "yum upgrade" command -- and the Apache/PHP/Imagick combo will still be working perfectly! Unlike some other guides out there for this, you don't need to rely on antiquated, unsupported versions that can be nearly impossible to find. Also, you don't need to worry about the MySQL, Hash, MBString, Exif packages, because they all seem to be installed and properly cooperating with PHP automatically after installing PHP from the Application Manager. This solution makes everything work well together.

== NGINX==




yum install wget make gcc gcc-c++ gtk+-devel zlib-devel openssl openssl-devel pcre-devel kernel keyutils patch perl


cd /usr/local/src #进入软件包存放目录
wget http://www.imagemagick.org/dow ... ar.gz #下载ImageMagick
tar zxvf ImageMagick.tar.gz #解压
cd ImageMagick-6.7.9-3 #进入安装目录
./configure --prefix=/usr/local/imagemagick #配置
make #编译
make install #安装
export PKG_CONFIG_PATH=/usr/local/imagemagick/lib/pkgconfig/ #设置环境变量


cd /usr/local/src
wget http://pecl.php.net/get/imagick-3.0.1.tgz #下载imagick
tar zxvf imagick-3.0.1.tgz
cd imagick-3.0.1
/usr/local/php5/bin/phpize #用phpize生成configure配置文件
./configure --with-php-config=/usr/local/php5/bin/php-config --with-imagick=/usr/local/imagemagick #配置
make #编译
make install #安装
Installing shared extensions: /usr/local/php5/lib/php/extensions/no-debug-non-zts-20090626/ #imagick模块路径


vi /usr/local/php5/etc/php.ini #编辑配置文件,在最后一行添加以下内容


vi /usr/local/nginx/html/phpinfo.php #编辑,输入以下代码
wq! #保存退出
vi /usr/local/nginx/html/imagick.php #编辑,输入以下代码
header('Content-type: image/jpeg');
$image = new Imagick('www.osyunwei.com.jpg');
// If 0 is provided as a width or height parameter,
// aspect ratio is maintained
$image->thumbnailImage(300, 225);
echo $image;