PHP扩展ImageMagick安装

2022-11-11 11:16 By "Powerless" 2735 1 0

【获取链接】

在pecl上查看需要安装的扩展链接

    1)下载

wget https://pecl.php.net/get/imagick-3.7.0.tgz

    2)解压缩

tar -zxvf imagick-3.7.0.tgz

    3)进入目录

cd imagick-3.7.0/

    4)建立php的外挂模块

/usr/local/php/bin/phpize

    5)生成Makefile

./configure --with-php-config=/usr/local/php/bin/php-config

    6)编译安装

make && make install

  

【可能出现的错误】

configure: error: not found. Please provide a path to MagickWand-config or Wand-config program.

    解决方案

yum install MagickWand-config

    1)可能出现的错误

Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package MagickWand-config

    2)解决方案

yum install libmagickcore-dev libmagickwand-dev


【再次生成Makefile】

./configure --with-php-config=/usr/local/php/bin/php-config

    1)编译安装

make && make install

    2)编译成功

....
PATH="$PATH:/sbin" ldconfig -n /root/imagick-3.7.0/modules
----------------------------------------------------------------------
Libraries have been installed in:
   /root/imagick-3.7.0/modules

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the `LD_RUN_PATH' environment variable
     during linking
   - use the `-Wl,--rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to `/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------

Build complete.
Don't forget to run 'make test'.

Installing shared extensions:     /usr/local/php/lib/php/extensions/no-debug-non-zts-20200930/
Installing header files:          /usr/local/php/include/php/

此时在/usr/local/php/lib/php/extensions/no-debug-non-zts-20200930/目录下就生成了编译的文件目录进入目录就会看到imagick.so文件了


【添加扩展】

vim /usr/local/php/etc/php.ini

在文件中加入一行

extension=imagick.so

重启PHP服务后就完了添加。

评 论

与众不同 0 2022-11-15 16:58
哈哈哈哈

Others Discussion

  • 必学十大经典排序算法,看这篇就够了
    Posted on 2019-11-18 16:30
  • Linux工具 - NM目标文件格式分析
    Posted on 2019-04-24 10:29
  • PHP练习-爬楼梯问题
    Posted on 2020-08-14 23:56
  • PHP练习-无重复字符的最长子串
    Posted on 2020-09-17 18:03
  • PHP练习-移动数组内的0到最后并保持其他元素顺序不变
    Posted on 2020-08-14 20:32
  • PHP设计模式 - 委托模式
    Posted on 2019-04-25 16:15
  • HTTP头中隐藏PHP版本号
    Posted on 2021-01-11 16:38
  • Composer 异常 [ErrorException]
    Posted on 2019-11-25 17:55