到目前为止我采取的步骤:
Fatal error: Class 'Imagick' not found
当我尝试运行使用 Imagick 的脚本时出错。 当前版本:
我运行的是旧版本的 PHP 并且让 Imagick 可以正常工作,然后我更新了 PHP(以及 Imagick DLL),现在我似乎无法让它工作。
看着
phpinfo( )
,我没有看到 Imagick 在那里列出,所以它似乎根本没有加载模块。这很奇怪,因为我在启动 Apache 时没有收到任何错误。我已经尝试了几乎所有在 Windows 上安装 Imagick for PHP 的文章和演练,但它们似乎都是为旧版本的 PHP 编写的。
有人可以帮我安装并运行它吗?似乎只是缺少一个我似乎无法弄清楚的简单步骤。如果您需要更多信息,请询问。我会尽我所能帮助你。
最佳答案
编辑:此过程也适用于 Windows 7 - 10 和所有版本的 PHP。
非官方网站可能会停止使用或稍后被更改为包含恶意代码。使用除官方 ImageMagick、PECL 或 PHP 站点以外的任何推荐链接或镜像时,请谨慎使用评论或其他答案中提供的链接。
我无法像最初接受的答案一样使用旧版本的 ImageMagick 使用 PHP 来让 Imagick 工作,并且很难找到具有精确 的镜像。安全二进制文件 需要(最初接受的答案中镜像上的二进制文件下载为与列出的版本不同的版本)
In all of the steps below, be sure to match your PHP architecture (x86/x64 and NTS/TS) to the binary's architecture. If you are using PHP x86 - replace the x64 version of the downloads with the x86 (or 32bit) version. The same applies to Thread-Safe (TS) and Non-Thread-Safe (NTS) versions of PHP.
PHP Imagick 扩展
并下载最新的 DLL
(3.3.0RC1)
在这个答案的时候。php_imagick.dll
至 D:\php5.6\ext
CORE_RL_*.dll
文件到 D:\php5.6
- D:\php5.6
已添加到 PATH
您的系统环境变量 extension = php_imagick.dll
至 D:\php5.6\php.ini
phpinfo();
确保模块安装正确 注意突出显示的 ImageMagick 版本 (ImageMagick 6.9.1-2 Q16 x64)
和缺少的支持格式 ImageMagick 二进制
D:\php5.6\bin
来自 https://www.imagemagick.org/script/download.php - 确保 Add Path to Environment Variables
选项被选中或手动添加 convert --version
显示正确的版本 CORE_RL_*.dll
中的文件D:\php5.6
(它们将通过 ImageMagick 路径加载 - 否则您的 PHP 安装可能会因 PECL dll 变得不稳定)phpinfo();
确保模块仍然正确安装并且现在正在加载 Imagick 支持的格式 Imagick PDF 作为图像支持 - Ghostscript(可选)
D:\php5.6\bin
能够将 PDF 转换为来自 http://sourceforge.net/projects/ghostscript/ 的图像确保与您的安装架构相匹配 我不需要添加
MAGICK_HOME
Imagick 使用 PHP 内置 Web 服务器或 CGI 工作,但 Apache 可能需要使用 mod_php
.见 特别注意事项 以下部分了解更多详情。PECL Imagick 依赖项 (1b)
您也可以下载所需的 ImageMagick 版本依赖项并解压缩
exe
和 dll
来自 bin
中的文件目录直接进入您的 D:\php5.6
目录。可以在 PECL 网站 http://windows.php.net/downloads/pecl/deps/ 上找到依赖项
Using the PECL dependencies removes the need to directly download and run the matching ImageMagick version installer from the vendor's website.
使用 PECL 依赖项方法时,使用 GhostScript 进行 PDF 转换所需的排除文件存在问题。
特别注意事项
确保运行 PHP 的用户有权执行
convert
.这应该通过 D:\php5.6\bin
继承但如果您选择安装到 C:\Program Files
.由于权限受限,您可能会遇到问题。请务必重新排列您的
PATH
系统环境变量使 %SystemRoot%\system32\convert.exe
不会覆盖 D:\php5.6\bin\convert.exe
.通过将您的 PHP 路径添加到 system32 的左侧,如下所示:路径:
D:\php5.6\bin;%SystemRoot%\system32;%SystemRoot%;...
这将强制您的系统在
D:\php5.6\bin
中查找可执行文件。之前 %SystemRoot%\system32
替换 D:\php5.6\bin\convert.exe
使用您安装 ImageMagick 的路径或路径 convert.exe
位于https://technet.microsoft.com/en-us/library/cc723564.aspx#XSLTsection127121120120
关于php - 在 Windows 上为 PHP 和 Apache 安装 Imagick,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27193631/