使用 php/windows 安装 ImageMagick 扩展
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2858439/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Installing ImageMagick extension with php/windows
提问by Jason
Running PHP Version 5.2.5 on Windows Server 2003 with IIS.
在带有 IIS 的 Windows Server 2003 上运行 PHP 版本 5.2.5。
Have virtually an identical server where we were able to install ImageMagick with no issues. It's running exactly the same version of php. Used the following steps to install, but it just won't seem to work on this server. ImageMagick itself is installed but php won't load the extension.
拥有几乎完全相同的服务器,我们可以在其中毫无问题地安装 ImageMagick。它运行的是完全相同版本的 php。使用以下步骤进行安装,但它似乎无法在此服务器上运行。ImageMagick 本身已安装,但 php 不会加载扩展。
We've spent hours trying to get the extension installed. It just won't show up in phpinfo().
我们花了几个小时试图安装扩展。它只是不会出现在 phpinfo() 中。
INSTALL STEPS TAKEN
安装步骤
To install IMagick on Windows XP (PHP 5.2.x)
在 Windows XP (PHP 5.2.x) 上安装 IMagick
download and install
ImageMagick-6.5.8-7 Q16-windows-dll.exehttp://www.imagemagick.org/download/binaries/ImageMagick-6.5.8-7-Q16-windows-dll.exedownload
php_imagick_dyn-Q16.dllfrom http://valokuva.org/outside-blog-content/imagick-windows-builds/080709/copy DLL to [PHP]/extension dir and rename it to
php_imagick.dllYou have to edit your
php.inifile and add the new extension:extension=php_imagick.dllSave
php.iniand restart Apache server. (If necessary, restart Windows)phpinfo()should showimagickenabled.
下载并安装
ImageMagick-6.5.8-7 Q16-windows-dll.exehttp://www.imagemagick.org/download/binaries/ImageMagick-6.5.8-7-Q16-windows-dll.exephp_imagick_dyn-Q16.dll从 http://valokuva.org/outside-blog-content/imagick-windows-builds/080709/下载将 DLL 复制到 [PHP]/extension 目录并将其重命名为
php_imagick.dll您必须编辑
php.ini文件并添加新扩展名:extension=php_imagick.dll保存
php.ini并重新启动 Apache 服务器。(如有必要,请重新启动 Windows)phpinfo()应该显示已imagick启用。
回答by ilNebbioso
Found veryuseful tha answer given by user Buttercup, also if he could be more clear.
发现用户 Buttercup 给出的答案非常有用,如果他能更清楚的话。
My scenario was a Windows 2012 R2 x64, PHP 5.5.19 x64 and need to install ImageImagick with PHP support. Following points here below I was able to install ImageImagick 6.9.0 x64 and PHP_Imagick.dll 3.1.2 (both are currently the latest stable versions).
我的场景是 Windows 2012 R2 x64、PHP 5.5.19 x64,需要安装支持 PHP 的 ImageImagick。以下几点我能够安装 ImageImagick 6.9.0 x64 和 PHP_Imagick.dll 3.1.2(两者都是目前最新的稳定版本)。
Please note I downloaded allcomponents (PHP, ImageImagick and PHP_Imagick) in NTS and x64 modes: not in TS and/or x86 modes. I don't know if this apply in your own case.
请注意,我在 NTS 和 x64 模式下下载了所有组件(PHP、ImageImagick 和 PHP_Imagick):不是在 TS 和/或 x86 模式下。我不知道这是否适用于您自己的情况。
The point it wasn't clear for me reading the Buttercup (as for user RhoVisions) was his comment: "Overwrite the DLLs found from ImageMagick 6.8.8 Windows version with the PHP version".
我在阅读 Buttercup(对于用户 RhoVisions)时不清楚的一点是他的评论:“用 PHP 版本覆盖从 ImageMagick 6.8.8 Windows 版本中找到的 DLL”。
So, this is what I've done (based on Buttercup solution, who I have to say again and again thank you very much!): 1) download latest ImageMagick EXE installer from http://www.imagemagick.org/script/binary-releases.php#windowsIn my case I downloaded the first file available as HTTP download labeled "Win64 dynamic at 16 bits-per-pixel" (filename: ImageMagick-6.9.0-0-Q16-x64-dll.exe)
所以,这就是我所做的(基于 Buttercup 解决方案,我不得不一次又一次地说非常感谢你!):1)从http://www.imagemagick.org/script/下载最新的 ImageMagick EXE 安装程序binary-releases.php#windows在我的例子中,我下载了第一个可用的 HTTP 下载文件,标记为“Win64 dynamic at 16 bits-per-pixel”(文件名:ImageMagick-6.9.0-0-Q16-x64-dll.exe)
2) Run the installer just downloaded. I installed it in a simple path like C:\ImageMagick6.9.0 (but I don't think it is so important to move it away from Program Files). Also, I didn't change any other parameter from their defaults during installing.
2) 运行刚刚下载的安装程序。我将它安装在一个简单的路径中,比如 C:\ImageMagick6.9.0(但我认为将它从 Program Files 中移开并不重要)。此外,我在安装过程中没有更改任何其他参数的默认值。
3) download latest PHP_Imagick DLL file from PECL website at: http://pecl.php.net/package/imagickI choosed a stable (not Beta or RC) version, in my case 3.1.2, clicking on the "Windows logo"+"DLL" label. In my case it was linked to ht tp://pecl.php.net/package/imagick/3.1.2/windows . On the page it will open you'll find a table: you have to choose your file depending on: a) number of version of PHP you have (in my case there were available DLLs for PHP 5.3, 5.4, 5.5, 5.6) b) x64 or x86 version of PHP you have c) NTS or TS version of PHP you have My case is was PHP 5.5.x, x64, NTS: so I downloaded the one labeled "5.5 Non Thread Safe (NTS) x64" (file name: php_imagick-3.1.2-5.5-nts-vc11-x64.zip)
3) 从 PECL 网站下载最新的 PHP_Imagick DLL 文件:http://pecl.php.net/package/imagick 我选择了一个稳定的(不是 Beta 或 RC)版本,在我的例子中是 3.1.2,点击“Windows 标志” “+”DLL”标签。在我的情况下,它链接到 ht tp://pecl.php.net/package/imagick/3.1.2/windows 。在它将打开的页面上,您会找到一个表格:您必须根据以下条件选择文件:a) 您拥有的 PHP 版本数(在我的情况下,有适用于 PHP 5.3、5.4、5.5、5.6 的可用 DLL)b ) 您拥有的 PHP 的 x64 或 x86 版本 c) 您拥有的 PHP 的 NTS 或 TS 版本 我的情况是 PHP 5.5.x、x64、NTS:所以我下载了一个标有“5.5 非线程安全 (NTS) x64”(文件名称:php_imagick-3.1.2-5.5-nts-vc11-x64.zip)
4) Unzip the php_imagick ZIP and: a) copy php_imagick.dll file into the EXT folder of your PHP installation b) copy and replace ALL the CORE_RL_.dll from the folder you just unzipped into the folder you choosed at point #2. Obviously, please backup replaced files. In my case I copied 8 CORE_RL_.dll files from unzipped folder to C:\ImageMagick6.9.0. I leaved into C:\ImageMagick6.9.0 the others CORE_RL_*.dll not overwritten.
4) 解压缩 php_imagick ZIP 并: a) 将 php_imagick.dll 文件复制到 PHP 安装的 EXT 文件夹中 b) 将您刚刚解压到您在第 2 点选择的文件夹中的所有 CORE_RL_ .dll复制并替换。显然,请备份替换的文件。就我而言,我将 8 个 CORE_RL_.dll 文件从解压缩的文件夹复制到 C:\ImageMagick6.9.0。我离开了 C:\ImageMagick6.9.0 其他 CORE_RL_*.dll 没有被覆盖。
5) Edit and save your PHP.ini file in order to add this simple row: extension=php_imagick.dll
5) 编辑并保存您的 PHP.ini 文件以添加以下简单行:extension=php_imagick.dll
6) Reboot your server (unfortunally I didn't find any good alternative of a reboot: also a IISRESET from admin command-prompt didn't work).
6)重新启动您的服务器(不幸的是,我没有找到任何好的重新启动替代方法:来自管理命令提示符的 IISRESET 也不起作用)。
7) When reboot finished, visit remotely by browser your phpinfo.php file in order to verify that Imagick module was ok. In my case it was.
7) 重启完成后,通过浏览器远程访问您的 phpinfo.php 文件以验证 Imagick 模块是否正常。就我而言,它是。
Hope this could help, out there!
希望这可以帮助,在那里!
回答by buttercup
I found an alternate source. PECL direct downloading.
我找到了一个替代来源。PECL直接下载。
Install Steps taken
安装步骤
ImageMagick installation
ImageMagick 安装
Where to download latest ImageMagic compatible with IIS 8.1 / Windows 2012r2 php x64:
在哪里下载与 IIS 8.1 / Windows 2012r2 php x64 兼容的最新 ImageMagic:
http://windows.php.net/downloads/pecl/deps/
http://windows.php.net/downloads/pecl/deps/
navigate and download: ImageMagick-6.8.8-vc9-x86.zip for PHP 32-bit, 5.4.xx
导航和下载:ImageMagick-6.8.8-vc9-x86.zip for PHP 32-bit, 5.4.xx
ImageMagick-6.8.8-vc11-x86.zip for PHP 32-bit, 5.5.xx
ImageMagick-6.8.8-vc11-x86.zip for PHP 32-bit, 5.5.xx
ImageMagick-6.8.8-vc11-x64.zip for PHP 64-bit, 5.5.xx
ImageMagick-6.8.8-vc11-x64.zip 用于 PHP 64 位,5.5.xx
Tips:
提示:
Overwrite the DLLs found from ImageMagick 6.8.8 Windows version with the PHP version.
You need to reboot if files are locked in memory.
用 PHP 版本覆盖从 ImageMagick 6.8.8 Windows 版本中找到的 DLL。
如果文件被锁定在内存中,则需要重新启动。
php_imageMagick.dll location
php_imageMagick.dll 位置
http://windows.php.net/downloads/pecl/releases/imagick/
http://windows.php.net/downloads/pecl/releases/imagick/
download the appropriate DLLs.
下载相应的 DLL。
You get latest version of ImageMagick DLLs, php_imagemagick.dll (both non-thread-safe and thread-safe versions).
您将获得最新版本的 ImageMagick DLL,php_imagemagick.dll(非线程安全和线程安全版本)。
Tip:
提示:
If you get php5ts.dll missing, you downloaded the wrong version of php_imagemagic.dll and download other version.
if you are using IIS - use 'NTS' version - php_imagemagick_nts.dll
if you are using Apache - use 'TS' version - php_imagemagick_ts.dll
如果缺少 php5ts.dll,则说明您下载了错误版本的 php_imagemagic.dll 并下载了其他版本。
如果您使用的是 IIS - 使用“NTS”版本 - php_imagemagick_nts.dll
如果您使用的是 Apache - 使用“TS”版本 - php_imagemagick_ts.dll
回答by A23149577
In windows you should check 3 parameters when you want to add an extension to php server:
在 Windows 中,当您想向 php 服务器添加扩展时,您应该检查 3 个参数:
The compiler version which your php server compiled with (VC9 or VC10) which is indicated in
phpinfo().The PHP extension API number which is indicated in
phpinfo().The most important parameter is whether your web server is ts (thread safe) or nts (non thread safe) which is indicated in
phpinfo().
您的 php 服务器使用(VC9 或 VC10)编译的编译器版本,在
phpinfo().中指示的 PHP 扩展 API 编号
phpinfo()。最重要的参数是您的 Web 服务器是 ts(线程安全)还是 nts(非线程安全),这在
phpinfo().
I found to my experience that IIS is nts by default and the php extension should be compiled with nts php library in order to work properly in your web server. However, your extension and your php web server should be the same exactly in these three parameters if you want to load your extension properly.
根据我的经验,我发现 IIS 默认是 nts 并且 php 扩展应该使用 nts php 库进行编译,以便在您的 Web 服务器中正常工作。但是,如果您想正确加载您的扩展程序,您的扩展程序和您的 php Web 服务器在这三个参数中应该完全相同。
回答by Agilox
On both http://www.imagemagick.org/download/binaries/and http://valokuva.org/outside-blog-content/, there are multiple DLLs files: one for x64 and another for x86. If your Windows XP is 32-bit, you need to try x86 DLL.
在http://www.imagemagick.org/download/binaries/和http://valokuva.org/outside-blog-content/ 上,都有多个 DLL 文件:一个用于 x64,另一个用于 x86。如果您的 Windows XP 是 32 位,则需要尝试 x86 DLL。
回答by Michael Petrov
This is an older question, but I've ran into similar issues with PHP/IIS before. A couple things I could suggest to double check:
这是一个较旧的问题,但我之前遇到过类似的 PHP/IIS 问题。我可以建议仔细检查几件事:
- Use the phpinfo page to see if you're editing the right php.ini file, look at the "Loaded php.ini file" on the first page (as stupid as it sounds, I've done that before - sometimes PHP will look for it in its own folder, sometimes C:\Windows)
- also try to enable display_errors to On and error_reporting to E_ALL in php.ini and see if there are error messages at the very bottom of the phpinfo file. Typically it will at least acknowledge not being able to load your DLL.
- 使用 phpinfo 页面查看您是否正在编辑正确的 php.ini 文件,查看第一页上的“已加载的 php.ini 文件”(听起来很愚蠢,我之前已经这样做了 - 有时 PHP 会看起来因为它在它自己的文件夹中,有时是 C:\Windows)
- 还尝试在 php.ini 中启用 display_errors 到 On 和 error_reporting 到 E_ALL 并查看 phpinfo 文件的最底部是否有错误消息。通常它至少会确认无法加载您的 DLL。
回答by user724171
You do not need to restart windows. You need to restart the application pools running the PHP exe. This can be done by either resetting IIS (This is the best option to get all the application pools to reset). Or recycle the application pools that are running PHP.
您不需要重新启动 Windows。您需要重新启动运行 PHP exe 的应用程序池。这可以通过重置 IIS 来完成(这是重置所有应用程序池的最佳选择)。或者回收运行 PHP 的应用程序池。
回答by Matt H
nothing worked until I set the permissions on the imagick folder and c:\windows\temp (IUSR read/execute for imagick, read/write/execute for windows\temp).
直到我设置了 imagick 文件夹和 c:\windows\temp 的权限(imagick 的 IUSR 读/执行,windows\temp 的读/写/执行)之前,没有任何作用。
* I'm not 100% sure read/write/execute was necessary for windows\temp but it was listed on a site somewhere during my google surfing *
* 我不是 100% 确定 windows\temp 需要读/写/执行,但它在我的谷歌冲浪期间列在某个网站上*
Pretty sure the rebooting part is just to make sure the imagick folder is in your system path directory and showing up in phpinfo(), it was already in my path so I didn't have to reboot after setting the permissions.
很确定重启部分只是为了确保 imagick 文件夹在您的系统路径目录中并显示在 phpinfo() 中,它已经在我的路径中,所以我不必在设置权限后重新启动。
回答by n.podbielski
I know that it is old question but I got here by google so probably other will too. For them here is a quickest and easiest solution: https://mlocati.github.io/articles/php-windows-imagick.html
我知道这是个老问题,但我是通过谷歌来到这里的,所以其他人也可能会这样做。对他们来说,这是一个最快捷、最简单的解决方案:https: //mlocati.github.io/articles/php-windows-imagick.html
It worked for me and it is much easier then most voted answers here (and which seemed too complicated for me, like installing imagick as cmd.com command - what for?)
它对我有用,而且比这里大多数投票的答案要容易得多(这对我来说似乎太复杂了,比如将 imagick 安装为 cmd.com 命令 - 有什么用?)
回答by Jens A. Koch
It's quite complicated to match the imagick extensions to their base and to the PHP version. So, in order to take out the hassles of the installation, i would suggest to use a server stack which ships Imagick and it's extension, like WPN-XM.
将 imagick 扩展与其基础和 PHP 版本相匹配是相当复杂的。因此,为了消除安装的麻烦,我建议使用一个包含 Imagick 及其扩展的服务器堆栈,例如WPN-XM。
回答by Martin
In my case Windows restart (mentioned in step 4) did the trick.
在我的情况下,Windows 重新启动(在第 4 步中提到)做到了。

