Background
Dear all,
I've installed PHP 8.2 on me Raspbian OS (PHP 8.x required by some libraries). I need to install the PHP imagemagick extension to convert images (SVG to PNG). However, I can't get it running.
Here is what i tried
Firstly, I installed imagemagick (don't know wheather that's necessary, but just to be on the safe side):
$ sudo apt install imagemagick
That was successful. There are no other packages avaiable:
$ sudo apt install imagemagick -a
imagemagick/oldstable,now 8:6.9.10.23+dfsg-2.1+deb10u1 armhf [installiert]
Secondly, I installed Imagick:
$ sudo apt install php-imagick
That was successful as well. There are no other packages avaiable:
$ sudo apt list php-imagick -a
php-imagick/oldstable,now 3.4.3-4.1 armhf [installiert]
I've added the following entry in my php.ini:
[Imagick]
extension=imagick.so
Finally, I restarted apache:
$ sudo systemctl restart apache2
During troubleshooting, I even restarted php:
$ sudo service php8.2-fpm reload
Problem and troubleshooting so far
Imagick doesn't show up, neither when I try php -r 'phpinfo();' | grep imagick
nor php -m | grep imagick
.
Saying that, of course $im = new \Imagick();
results in a
Fatal error: Uncaught Error: Class "Imagick" not found
.
I've studied web pages (including php error: Class 'Imagick' not found) and manuals for more than two hours now without any success. Any help/hint is highly appreciated!
Edit: Hints found so far
Maybe one hint is that imagick.so was installed in the directory /usr/lib/php/20180731
, while the current php extensions directory (according to php.ini) is /usr/lib/php/20220829
. Copying the file to 20220829
(and restarting the services) didn't help.
Another hint might be that /etc/php/7.3/cli/conf.d
contains a (link file) 20-imagick.ini
(pointing to /etc/php/7.3/mods-available/imagick.ini
), while /etc/php/8.2/cli/conf.d
doesn't contain such a link, and /etc/php/8.2/mods-available
doesn't contain an imagick.ini
file. Same is applicable for /etc/php/x.y/apache2/conf.d
. That seems suspicious, so I copied the following files
/etc/php/7.3/mods-available/imagick.ini -> /etc/php/8.2/mods-available/imagick.ini [content: extension=imagick.so]
/etc/php/7.3/cli/conf.d/20-imagick.ini -> /etc/php/8.2/cli/conf.d/20-imagick.ini
/etc/php/7.3/apache2/conf.d/20-imagick.ini -> /etc/php/8.2/apache2/conf.d/20-imagick.ini
/etc/php/7.3/fpm/conf.d/20-imagick.ini -> /etc/php/8.2/fpm/conf.d/20-imagick.ini
/usr/lib/php/20180731/imagick.so -> /usr/lib/php/20220829/imagick.so
After $ sudo systemctl restart apache2
when I run $ php -m | grep imagick
I now get
PHP Warning: PHP Startup: Unable to load dynamic library 'imagick.so' (tried: /usr/lib/php/20220829/imagick.so (/usr/lib/php/20220829/imagick.so: undefined symbol: add_next_index_zval), /usr/lib/php/20220829/imagick.so.so (/usr/lib/php/20220829/imagick.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
Maybe for some reason apt install and/or php-imagick think that my current php version is 7.3, so it updated the wrong files and took the wrong shared library (imagick.so), while it is 8.2 (7.3 is still installed, but inactive and 8.2 is active)?
Found this link here, that at least matches the error message: The propcedure entry point add_index_zval could not be located in the dynamic link library xampp/php/ext/php_imagic.dll
Possible solution: I have to get Imagick version>=3.5.0, according to the change log https://pecl.php.net/package-changelog.php?package=imagick, in order to have PHP 8.x supported (hopefully 8.2).