centos 6.5 下imagick扩展,怎么安装


centos 6.5 下imagick扩展,怎么安装
已邀请:

admin

赞同来自:


==XAMPP==

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.
;;;;

extension=imagick.so

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==

说明:

php安装目录:/usr/local/php5
php.ini配置文件路径:/usr/local/php5/etc/php.ini
Nginx安装目录:/usr/local/nginx
Nginx网站根目录:/usr/local/nginx/html

1、安装编译工具

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

2、安装ImageMagick

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/ #设置环境变量

3、安装imagick

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模块路径

4、配置php支持imagick

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

5、测试

vi /usr/local/nginx/html/phpinfo.php #编辑,输入以下代码
<?php
phpinfo();
?>
wq! #保存退出
vi /usr/local/nginx/html/imagick.php #编辑,输入以下代码
<?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;
?>

要回复问题请先登录注册