You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Ubuntu系统下PHP7.3安装Imagick扩展失败,Laravel Intervention Image无法切换至Imagick驱动

Ubuntu系统下PHP7.3安装Imagick扩展失败,Laravel Intervention Image无法切换至Imagick驱动

我在Laravel项目里用Intervention Image库,想把驱动从GD换成Imagick,结果在Ubuntu服务器的PHP7.3环境下卡壳了,折腾了好几种方法都没解决,具体情况如下:

问题现象

执行php -ini查看配置时,显示的配置路径是/etc/php/7.3/cli,同时弹出PHP启动警告:

PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/20170718/imagick.so' (tried: /usr/lib/php/20170718/imagick.so (/usr/lib/php/20170718/imagick.so: undefined symbol: _zval_ptr_dtor), /usr/lib/php/20180731//usr/lib/php/20170718/imagick.so.so (/usr/lib/php/20180731//usr/lib/php/20170718/imagick.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0

尝试过的操作

  1. 最初的安装尝试
    我用命令sudo apt-get install php-imagick安装Imagick扩展,但从安装日志能看出来,装的是适配PHP7.2的版本,根本不是我用的PHP7.3:

Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
php-imagick
0 upgraded, 1 newly installed, 0 to remove and 4 not upgraded.
Need to get 0 B/90.7 kB of archives.
After this operation, 477 kB of additional disk space will be used.
Selecting previously unselected package php-imagick.
(Reading database ... 103072 files and directories currently installed.)
Preparing to unpack .../php-imagick_3.4.3~rc2-2ubuntu4.1_amd64.deb ...
Unpacking php-imagick (3.4.3~rc2-2ubuntu4.1) ...
Setting up php-imagick (3.4.3~rc2-2ubuntu4.1) ...
Processing triggers for php7.2-phpdbg (7.2.24-0ubuntu0.18.04.17) ...
Processing triggers for php7.2-cli (7.2.24-0ubuntu0.18.04.17) ...

  1. 修改PHP配置文件
    我编辑了PHP7.3的CLI配置文件(命令:sudo nano /etc/php/7.3/cli/php.ini),分别试了两种配置方式,都没让PHP识别到Imagick模块:
  • extension=imagick.so
  • extension=/usr/lib/php/20170718/imagick.so
  1. 尝试安装对应版本的扩展
    我想直接装PHP7.3专属的Imagick扩展,执行sudo apt-get install php7.3-imagick,结果系统提示“Unable to locate package php7.3-imagick”。

  2. 查找扩展文件位置
    用sudo find /usr -name imagick.so查找Imagick的安装路径,得到的结果是:/usr/lib/php/20170718/imagick.so

备注:内容来源于stack exchange,提问作者gabogabans

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.21 16:19:27