在Windows上安装Imagick for PHP和Apache [英] Install Imagick for PHP and Apache on Windows

查看:78
本文介绍了在Windows上安装Imagick for PHP和Apache的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

到目前为止我已经采取的步骤:

Steps I've taken so far:

  1. 我已经在Win7机器上安装了Imagick,并且可以通过命令行正确安装并运行它.
  2. 我已经提取了php_imagick-3.1.2-5.6-ts-vc11-x86.zip的内容,该
  1. I have installed Imagick on my Win7 machine, and it's installed and running properly via command line.
  2. I've extracted the contents of php_imagick-3.1.2-5.6-ts-vc11-x86.zip available here into my \PHP\ext directory.
  3. Enabled the imagick.dll in php.ini
  4. Rebooted...
  5. No errors when starting Apache.
  6. I'm still getting the Fatal error: Class 'Imagick' not found error when I try to run a script that uses Imagick.

当前版本:

  • Windows 7 x64
  • Apache 2.4.10 x86 VC11 (from Apachelounge)
  • PHP 5.6.3 x86 VC11 TS (from windows.php.net)
  • ImageMagick 6.9.0-0 Q16 x86 (from imagemagick.org)
  • Imagick DLL php_imagick-3.1.2-5.6-ts-vc11-x86.zip (from here)

我运行的是旧版本的PHP,并且Imagick可以正常运行,然后我更新了PHP(以及Imagick DLL),但现在似乎无法正常工作.

I was running an older version of PHP and had Imagick working fine with that, then I updated PHP (and the Imagick DLLs along with it) and now I can't seem to get it to work.

看着phpinfo( ),我没有在此处看到Imagick的列表,因此它似乎根本没有加载该模块.太奇怪了,因为启动Apache时没有出现任何错误.

Looking at phpinfo( ), I don't see Imagick listed there, so it doesn't seem to be loading the module at all. Which is weird, because I'm not getting any errors when starting Apache.

我几乎尝试过在Windows上安装Imagick for PHP的所有文章和演练,但它们似乎都是针对较旧版本的PHP编写的.

I've tried just about every write-up and walkthrough for installing Imagick for PHP on Windows, but they seem to all be written for older versions of PHP.

有人可以帮助我安装并运行它吗?似乎只是缺少了一个我似乎无法弄清楚的简单步骤.如果您需要更多信息,请询问.我将竭尽所能为您服务.

Can somebody help me get this installed and running? It seems like it's just missing one simple step that I can't seem to figure out. If you need any more info, please ask. I'll get you whatever I can to help.

推荐答案

我已在Windows 8.1 pro上为我的开发系统安装了 php 5.6 NTS x64 .

I have php 5.6 NTS x64 installed on Windows 8.1 pro for my Development System.

编辑:此过程也适用于Windows 10专业版.

This procedure worked with Windows 10 pro as well.

我无法使用Imagick使用较旧版本的ImageMagick与PHP一起工作,如接受的答案中所述,并且很难找到需要确切安全二进制文件的镜像(接受的答案中镜像上的二进制文件已下载为不同版本)比列出的要多).

I was unable to get Imagick Working with PHP using an older release of ImageMagick as in the accepted answer and it was difficult to find mirrors with the exact safe binaries needed (the binaries on the mirror in the accepted answer downloaded as different versions than listed).

在下面的所有步骤中,请确保将您的PHP体系结构(x86/x64和NTS/TS)与二进制体系结构相匹配.如果您使用的是PHP x86,请用x86(或32位)版本替换下载的x64版本.同样适用于PHP的线程安全(TS)和非线程安全(NTS)版本.

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.

通过执行以下操作,我终于使所有工作正常进行:

I finally got it all working by performing the following:

  1. 导航到 https://pecl.php.net/package/imagick 并在回答此问题时下载最新的DLL (3.3.0RC1) .
  2. php_imagick.dll 提取为 D:\php5.6\ext
  3. 将所有 CORE_RL_*.dll 文件提取到 D:\php5.6 -确保将 D:\php5.6 添加到PATH系统环境变量
  4. extension = php_imagick.dll 添加到 D:\php5.6\php.ini
  5. 重新启动Apache/PHP内置Web服务器
  6. 检查PHP信息以确保正确安装了模块 请注意突出显示的ImageMagick版本 (ImageMagick 6.9.1-2 Q16 x64) 以及缺少的受支持格式
  1. Navigate to https://pecl.php.net/package/imagick and download the latest DLL (3.3.0RC1) at time of this answer.
  2. Extract php_imagick.dll to D:\php5.6\ext
  3. Extract all CORE_RL_*.dll files to D:\php5.6 - Ensure D:\php5.6 is also added to the PATH of your system environment variables
  4. Add extension = php_imagick.dll to D:\php5.6\php.ini
  5. Restart Apache/PHP Built-In Web Server
  6. Check PHP Info to ensure the module is installed correctly Note the highlighted ImageMagick version (ImageMagick 6.9.1-2 Q16 x64) and the missing supported formats
  7. Download and install the matching version of ImageMagick to D:\php5.6\bin from http://www.imagemagick.org/script/binary-releases.php - Ensure that the Add Path to Environment Variables option is checked or manually add it .
  8. Load a command prompt (run as administrator which forces the system path variable to refresh) and ensure convert --version displays the correct version
  9. Delete the previously extracted CORE_RL_*.dll files in D:\php5.6 (they will be loaded via ImageMagick path - otherwise your PHP installation may become unstable with the PECL dlls)
  10. Restart Apache/PHP Built-In Web Server
  11. Check PHP Info to ensure module is still installed correctly and is now loading the Imagick supported formats
  12. Optionally download and install Ghostscript to D:\php5.6\bin to be able to convert PDFs to images from http://sourceforge.net/projects/ghostscript/ be sure to match the architecture for your installation

我不需要添加MAGICK_HOME即可使Imagick使用PHP内置Web服务器或CGI进行工作,但是Apache可能需要使用mod_php来运行.确保运行PHP的用户有权执行convert.这应该通过D:\php5.6\bin继承,但是如果您选择安装到C:\Program Files.由于权限受限,您可能会遇到问题.

I did not need to add MAGICK_HOME for Imagick to work using the PHP Built-In Web Server or CGI, but may be required for Apache using mod_php. Be sure the user running PHP has permission to execute convert. This should be inherited via D:\php5.6\bin but in case you chose to install to C:\Program Files. you may have issues due to its restricted permissions.

图像转换的替代方式

如评论中所述,您也可以下载必需的ImageMagick版本依赖项,并将exedll文件从bin目录中直接提取到您的 D:\php5.6 目录中. 依赖性可以在PECL网站上找到 http://windows.php.net/downloads/pecl /deps/

As noted in the comments, you can alternatively download the required ImageMagick version dependencies and extract the exe and dll files from within the bin directory directly into your D:\php5.6 directory. The dependencies can be found on PECL website http://windows.php.net/downloads/pecl/deps/

使用PECL依赖项无需直接下载和 从供应商的网站运行匹配的ImageMagick版本安装程序.

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转换所需的排除文件存在问题.

特殊注意事项

请确保重新排列PATH系统环境变量,以使%SystemRoot%\system32\convert.exe不会覆盖D:\php5.6\bin\convert.exe.

Be sure to rearrange your PATH System Environment Variable so that %SystemRoot%\system32\convert.exe does not override the D:\php5.6\bin\convert.exe.

通过将您的PHP路径添加到system32的左侧,如下所示: PATH:D:\php5.6\bin;%SystemRoot%\system32;%SystemRoot%;...

By adding your PHP path to the left of system32, like so: PATH: D:\php5.6\bin;%SystemRoot%\system32;%SystemRoot%;...

这将迫使您的系统在%SystemRoot%\system32

D:\php5.6\bin\convert.exe替换为您安装ImageMagick的路径或convert.exe所在的路径

Replace D:\php5.6\bin\convert.exe with the path to where you installed ImageMagick or the path to where convert.exe is located

https://technet.microsoft.com/en-us /library/cc723564.aspx#XSLTsection127121120120

这篇关于在Windows上安装Imagick for PHP和Apache的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆