简体   繁体   English

无法为 php7.4 加载 Imagick

[英]Failed to get Imagick load for php7.4

I know there has been a lot of question asked regarding installing imagick to Php7+, unfortunately all the answer doesn't solve my issue.我知道有很多关于将 imagick 安装到 Php7+ 的问题,不幸的是所有答案都不能解决我的问题。

I just update to php7.4, so I follow the previous setting from 7.3, 7.2 to enabled imagick, basically:我刚刚更新到php7.4,所以我按照之前的设置从7.3、7.2到启用imagick,基本上:

echo extension=imagick.so > /etc/php/7.4/mods-available/imagick.ini

then soft link to "fpm" and "cli" directory:然后软链接到“fpm”和“cli”目录:

ln -s /etc/php/7.4/mods-available/imagick.ini /etc/php/7.4/fpm/conf.d/20-imagick.ini
ln -s /etc/php/7.4/mods-available/imagick.ini /etc/php/7.4/cli/conf.d/20-imagick.ini

reloaded the php7.4-fpm, but imagick still failed to load重新加载了php7.4-fpm,但imagick仍然无法加载

verify with php -i |验证php -i | grep imagick but got an error of: grep imagick但出现以下错误:

PHP Warning:  PHP Startup: Unable to load dynamic library 'imagick.so' (tried: /usr/lib/php/20190902/imagick.so (/usr/lib/php/20190902/imagick.so: cannot open shared object file: No such file or directory), /us
r/lib/php/20190902/imagick.so.so (/usr/lib/php/20190902/imagick.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0

Note:笔记:
- I have tried to purge php-imagick and reinstall it, but doesn't work . - 我试图清除php-imagick 并重新安装它,但不起作用

I solved it on my raspi this way (based on the instructions here: How to Install PHP imagick extension ):我以这种方式在我的 raspi 上解决了它(基于此处的说明: 如何安装 PHP imagick 扩展):

  • sudo apt install php7.4-dev (if not already installed) sudo apt install php7.4-dev (如果尚未安装)
  • check your pecl Version (must match with 7.4): pecl version检查您的pecl版本(必须与 7.4 匹配): pecl version
  • make sure that sed is executable from /bin/sed (the pecl install needs it to be there, I had to symlink it from /usr/bin/sed )确保sed可以从/bin/sed执行( pecl install需要它在那里,我必须从/usr/bin/sed符号链接它)
  • sudo apt install libmagickwand-dev
  • sudo pecl install imagick

Then you can carry on with the steps you already made:然后你可以继续你已经做的步骤:

sudo echo extension=imagick.so > /etc/php/7.4/mods-available/imagick.ini
sudo ln -s /etc/php/7.4/mods-available/imagick.ini /etc/php/7.4/fpm/conf.d/20-imagick.ini
sudo ln -s /etc/php/7.4/mods-available/imagick.ini /etc/php/7.4/cli/conf.d/20-imagick.ini

After that, restart your services (php7.4-fpm, apache, nginx, ...).之后,重新启动您的服务(php7.4-fpm,apache,nginx,...)。

Hope this helps!希望这可以帮助!

Also got this error and took a solid 2 hours to solve:也得到了这个错误,花了整整 2 个小时来解决:

PHP Warning:  PHP Startup: Unable to load dynamic library 'imagick.so' (tried: /usr/lib/php/20190902/imagick.so (/usr/lib/php/20190902/imagick.so: cannot open shared object file: No such file or directory), /phpusr/lib/php/20190902/imagick.so.so (/usr/lib/php/20190902/imagick.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0

Even though php -i showed that my configured php version was 7.4 and that imagick extension was installed, I could not get rid of this warning.即使php -i显示我配置的 php 版本是 7.4 并且安装了 imagick 扩展,我还是无法摆脱这个警告。
So after running alot of commands and reading on the net, I figured the most obvious thing to do is check the given directory /usr/lib/php/20190902/ .所以在运行了很多命令并在网上阅读之后,我认为最明显的事情是检查给定的目录/usr/lib/php/20190902/
So annoyingly even after installing imagick with即使在安装了 imagick 之后也很烦人

sudo apt install php-imagick

it was not installed in that directory, but was for php8.0.它没有安装在该目录中,而是用于 php8.0。 This command这个命令

apt search imagick

had already showed this,已经表明了这一点,

php7.4-imagick/focal,now 3.5.1-1+ubuntu20.04.1+deb.sury.org+1 amd64 
  Provides a wrapper to the ImageMagick library

php8.0-imagick/focal,now 3.5.1-1+ubuntu20.04.1+deb.sury.org+1 amd64 [installed,automatic]
  Provides a wrapper to the ImageMagick library

but I did not grasp [installed] being missing.但我没有掌握 [已安装] 丢失。

Solution in the end was to install my configured php version specific imagick with最后的解决方案是安装我配置的 php 版本特定的 imagick

sudo apt install php7.4-imagick

I checked if installed with php -m | grep imagick我检查了是否安装了php -m | grep imagick php -m | grep imagick and double checked with ll /usr/lib/php/20190902 and ran command sudo systemctl restart apache2 before all was well again. php -m | grep imagick并用ll /usr/lib/php/20190902检查并运行命令sudo systemctl restart apache2之前一切都很好。

To install Imagick run bellow command:要安装 Imagick,请运行以下命令:
sudo apt-get install php-imagick

For specific PHP version (in my case 7.1):对于特定的 PHP 版本(在我的情况下为 7.1):
sudo apt-get install php7.1-imagick

Then restart apache:然后重启apache:
sudo service apache2 restart

To check if the extension has been installed:检查扩展是否已安装:
php -m | grep imagick

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM