PHP Startup: Unable to load dynamic library ‘imagick’ 【解决】无需复制dll到bin目录,windows下配置imagick扩展(Nginx)
场景:
主要解决:ImageMagick number of supported formats:0 。PHP Startup: Unable to load dynamic library ‘imagick’。这两种问题。
重点是设置完windows系统
环境变量后,要重启或注销
系统后,php才能正常识别imagick扩展。经过测试,php7.3、7.4、8.0此方法均适用,8.1未测试。
完整步骤
1.使用php -m 命令查看php扩展加载情况。下图是没有加载imagick扩展。
2.到PECL网站下载imagick的windows扩展包。
3.选择对应版本的PHP扩展,下载到本地。我用的是Nginx1.23,所以我下载nts版本。
4.将下载的压缩包解压到本地,可以是任意位置。以前教程都是解压到C盘,经过我测试其实哪个位置都行,主要是设置好环境变量。
5.设置好imagick的位置的环境变量。如下图,注意路径要正确。
6.设置好以后,到PHP根目录,修改php.ini配置文件,增加一行,保存。
7.将php_imagick-3.7.0-8.0-nts-vs16-x64文件夹中的dll扩展文件,复制到php的ext文件夹下。
8.重启或者注销系统一下。(重要步骤,如果不重启直接去试imagick扩展,会出现奇奇怪怪问题。其他教程没有提到。)
10.验证扩展是否安装成功。以下是使用php -m 命令、phpinfo()、new Imagick() 三种方法进行验证。
环境说明
Windows 10 X64 LTSC
PHP:8.0.2
Nginx 1.23
imagick扩展:php_imagick-3.7.0-8.0-nts-vs16-x64
PHP官网的安装说明(Apache例子)
If there is no “imagick” section or “supported format” is 0,
something went wrong.
I initially followed:
http://php .net/manual/en/imagick.installation.php
but after installation, PHPInfo under imagick shows
number of supported formats = 0
So I followed these steps, clobbered from various sources
to get it to work.
-
Open PHPInfo and check:
Architecture = x86 or x64
Thread Safety = yes or no -
Download ImageMagick from:
http://windows.php.net/downloads/pecl/deps/
In my case I downloaded: ImageMagick-6.9.3-7-vc11-x86.zip
because the Architecture under PHPInfo is x86
as for vc11 or vc14
search google for “visual c++ 11 runtime” or
“visual c++ 14 runtime” and install it -
Unzip and copy all dlls from the bin subfolder to the
Apache bin directory. It’s a bunch of CORE_RL_.dll
and IM_MOD_RL_.dll plus a few other dlls.In my case, I installed UwAmp in C:\UwAmp, so:
(from zip) bin/*.dll --> C:\UwAmp\bin\apache\bin
4. Goto:http://pecl.php.net/package/imagick
as of today, latest is 3.4.1 so I went to:
http://pecl.php.net/package/imagick/3.4.1/windowsMy PHP version is: 5.6.18, and Thread Safety is Yes from
Step #1, so I downloaded:
5.6 Thread Safe (TS) x86
I got: php_imagick-3.4.1-5.6-ts-vc11-x86.zip -
Unzip and copy “php_imagick.dll” to the php extension folder:
In my case:
php_imagick.dll --> C:\UwAmp\bin\php\php-5.6.18\extNote: this ZIP also contains dlls which other guides says
to extract to the extension folder of apache.
NO NEED TO DO IT. Step #3 has taken care of it. -
Edit “php.ini” and add at the very end (could be
anywhere I suppose):[Imagick]
extension=php_imagick.dllFor super newbies: click the edit button in the UwAmp UI,
“php_uwamp.ini” will open and edit it. It will be copied to
the correct php.ini when UwAmp is restarted. I had
trouble at first since there are several php*.ini scattered
all over. -
Restart Apache
-
Check PHPInfo
scroll to section (or find): imagick
number of supported formats: 234
Hope this helps.
参考
在 Windows 10 64 位、PHP 7.4.6 中,报错:PHP Warning: PHP Startup: Unable to load dynamic library ‘imagick’
免责声明:
① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。
② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341