php php错误:找不到“Imagick”类

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3790191/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 11:07:40  来源:igfitidea点击:

php error: Class 'Imagick' not found

php

提问by Andrew Thomas

I am getting the error "Class 'Imagick' not found". Somehow I need to make this library accessible to php. I am using Php 5.2.6 on Fedora 8. my php_info has no mention of ImageMagick.

我收到错误“找不到‘Imagick’类”。不知何故,我需要让 php 可以访问这个库。我在 Fedora 8 上使用 PHP 5.2.6。我的 php_info 没有提到 ImageMagick。

I have tried: yum install ImageMagick and restarted apache, which didn't work.

我试过: yum install ImageMagick 并重新启动 apache,但没有用。

I also added extension=imagick.ext to my php.ini file and restarted apache, which didn't work.

我还在我的 php.ini 文件中添加了 extension=imagick.ext 并重新启动了 apache,但它不起作用。

采纳答案by Andrew Thomas

From: http://news.ycombinator.com/item?id=1726074

来自:http: //news.ycombinator.com/item?id=1726074

For RHEL-based i386 distributions:

对于基于 RHEL 的 i386 发行版:

yum install ImageMagick.i386
yum install ImageMagick-devel.i386
pecl install imagick
echo "extension=imagick.so" > /etc/php.d/imagick.ini
service httpd restart

This may also work on other i386 distributions using yum package manager. For x86_64, just replace .i386 with .x86_64

这也适用于使用 yum 包管理器的其他 i386 发行版。对于 x86_64,只需将 .i386 替换为 .x86_64

回答by Rodrigo Carmona

For all to those having problems with this i did this tutorial:

对于所有遇到此问题的人,我做了本教程:

How to install Imagemagick and Php module Imagick on ubuntu?

如何在 ubuntu 上安装 Imagemagick 和 Php 模块 Imagick?

i did this 7 simple steps:

我做了这7个简单的步骤:

Update libraries, and packages

更新库和包

apt-get update

Remove obsolete things

删除过时的东西

apt-get autoremove

For the libraries of ImageMagick

对于 ImageMagick 的库

apt-get install libmagickwand-dev

for the core class Imagick

对于核心类 Imagick

apt-get install imagemagick

For create the binaries, and conections in beetween

用于在 beetween 中创建二进制文件和连接

pecl install imagick

Append the extension to your php.ini

将扩展名附加到您的 php.ini

echo "extension=imagick.so" >> /etc/php5/apache2/php.ini

Restart Apache

重启阿帕奇

service apache2 restart


I found a problem. PHP searches for .so files in a folder called /usr/lib/php5/20100525, and the imagick.so is stored in a folder called /usr/lib/php5/20090626. So you have to copy the file to that folder.

我发现了一个问题。PHP 在名为 /usr/lib/php5/20100525 的文件夹中搜索 .so 文件,并将 imagick.so 存储在名为 /usr/lib/php5/20090626 的文件夹中。因此,您必须将文件复制到该文件夹​​中。

回答by Alastair

Ubuntu

Ubuntu

sudo apt-get install php5-dev pecl imagemagick libmagickwand-dev
sudo pecl install imagick
sudo apt-get install php5-imagick
sudo service apache2 restart

Some dependencies will probably already be met but excluding the Apache service, that's everything required for PHP to use the Imagickclass.

一些依赖项可能已经得到满足,但不包括 Apache 服务,这是 PHP 使用Imagick该类所需的一切。

回答by Gajen Sunthara

For MAMP running on Mac OSX

对于在 Mac OSX 上运行的 MAMP

Find out the what version of PHP and install the right version via brew

找出 PHP 的版本并通过 brew 安装正确的版本

brew install homebrew/php/php56-imagick

Add the extension by modifying the php.ini template in MAMP

通过修改MAMP中的php.ini模板添加扩展

enter image description here

在此处输入图片说明

Verify the Imagick

验证 Imagick

enter image description here

在此处输入图片说明

回答by Juergen

Debian 9

Debian 9

I just did the following and everything else needed got automatically installed as well.

我只是做了以下事情,其他需要的东西也自动安装了。

sudo apt-get -y -f install php-imagick
sudo /etc/init.d/apache2 restart

回答by Sadee

Install Imagic in PHP7:

在 PHP7 中安装 Imagic:

sudo apt-get install php-imagick

回答by emix

Docker container installation for php:XXXDebian based images:

php:XXX基于 Debian 的镜像的Docker 容器安装:

RUN apt-get update && apt-get install -y --no-install-recommends libmagickwand-dev
RUN pecl install imagick && docker-php-ext-enable imagick
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* || true

回答by Scott

On an EC2 at AWS, I did this:

在 AWS 的 EC2 上,我这样做了:

 yum list | grep imagick

Then found a list of ones I could install...

然后找到了我可以安装的列表...

 php -v

told me which version of php I had and thus which version of imagick

告诉我我拥有哪个版本的 php 以及哪个版本的 imagick

yum install php56-pecl-imagick.x86_64

Did the trick. Enjoy!

做到了。享受!