简体   繁体   中英

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.

I just update to php7.4, so I follow the previous setting from 7.3, 7.2 to enabled imagick, basically:

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

then soft link to "fpm" and "cli" directory:

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

verify with php -i | grep imagick but got an error of:

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 .

I solved it on my raspi this way (based on the instructions here: How to Install PHP imagick extension ):

  • sudo apt install php7.4-dev (if not already installed)
  • check your pecl Version (must match with 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 )
  • 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, ...).

Hope this helps!

Also got this error and took a solid 2 hours to solve:

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.
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/ .
So annoyingly even after installing imagick with

sudo apt install php-imagick

it was not installed in that directory, but was for 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

sudo apt install php7.4-imagick

I checked if installed with 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.

To install Imagick run bellow command:
sudo apt-get install php-imagick

For specific PHP version (in my case 7.1):
sudo apt-get install php7.1-imagick

Then restart apache:
sudo service apache2 restart

To check if the extension has been installed:
php -m | grep imagick

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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