CentOS 8.2 配置 PHP7.4 GraphicsMagick

发布于 作者 量尺寸留下评论

首先说明下,在CentOS 8 的默认环境下,dnf 已经取代了 yum 用于软件管理。而ImageMagick 也被 GraphicsMagick 所取代。基于这样的情况,本文介绍如何在 CentOS 8 下配置使用 GraphicsMagick,并安装 PHP7.4 的 GMagick 扩展模块。以下操作均基于CentOS 8.2 Apahce2 PHP7.4 php-fpm 环境下,使用root权限。

一、安装 GraphicsMagick ,逐条运行以下命令:

install php-pear php-devel gcc
dnf info GraphicsMagick
dnf install GraphicsMagick GraphicsMagick-devel GraphicsMagick-perl

二、安装 GMagick PHP Extension,逐条运行以下命令:

cd /usr/local/src
wget https://pecl.php.net/get/gmagick
tar xfvz gmagick
cd gmagick-*
phpize
./configure
make
make install

上述phpize指令如提示需要依赖,则照提示安装后再运行。

如果使用PHP默认的配置文件路径,将启用 GMagick 扩展的指令添加到 php.ini 文件中:

echo extension=gmagick.so >> /etc/php.ini

重启 php-fpm(如果PHP是以php-fpm模式运行),重启 httpd 服务(非 php-fpm模式只需重启httpd)。

systemctl restart php-fpm
systemctl restart httpd

使用 php -m | grep gmagick 检查PHP是否加载了gmagick扩展模块。

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注