Failed to get Imagick load for php7.4 - php

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 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

Related

GRPC php extension Ubuntu 20.04 + Plesk

I installed grpc for a project using Ubuntu 20.04 with PLESK and SSH.
Installation is successful, before I run following commands:
apt-get -y install gcc make autoconf libc-dev pkg-config
apt-get -y install libgpgme11-dev apt-get -y install php-pear
apt-get -y install php-dev
cd /opt/plesk/php/8.0/bin
pecl install grpc
After installation the grpc.so file was stored under: /usr/lib/php/20190902/grpc.so
I manually copied it from there to the php plesk path:
cp /usr/lib/php/20190902/grpc.so /opt/plesk/php/8.0/lib/php/modules/grpc.so
Reread the php binaries
plesk bin php_handler --reread
Reboot the server (to make sure everything is restarted).
Under /opt/plesk/php/8.0/etc/php.d/grpc.ini the content is: extension=grpc.so
Then the extension is shown in plesk if I click on the php Version. I can activate the extension and deactivate it.
That comments in or out in the /opt/plesk/php/8.0/etc/php.d/grpc.ini
But in my php-code it is not working:
"Uncaught Google\Cloud\Core\Exception\GoogleException: The requested client requires the gRPC extension"
If I run:
/opt/plesk/php/8.0/bin/php -m | grep grpc
The output is:
PHP Warning: PHP Startup: grpc: Unable to initialize module
Module compiled with module API=20200930
PHP compiled with module API=20190902
These options need to match
In Windows with the precompiled .dll and XAMPP the code works fine.
phpinfo shows:
Additional .ini files parsed ---- /opt/plesk/php/8.0/etc/php.d/grpc.ini
But there is no extra section created and the extension is not loaded..

PHP Warning: PHP Startup: Unable to load dynamic library 'sqlsrv.so'

Hi i recently installed SQL Server on my machine. It has Ubuntu 16.04 LTS OS.
I followed this link to install server extensions for PHP 7.2 and now I'm getting these PHP warnings:
PHP Startup: Unable to load dynamic library 'pdo_sqlsrv.so'(tried: /usr/lib/php/20170718/pdo_sqlsrv.so (/usr/lib/php/20170718/pdo_sqlsrv.so: cannot open shared object file: No such file or directory), /usr/lib/php/20170718/pdo_sqlsrv.so.so (/usr/lib/php/20170718/pdo_sqlsrv.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
PHP Startup: Unable to load dynamic library 'sqlsrv.so' tried: /usr/lib/php/20170718/sqlsrv.so (/usr/lib/php/20170718/sqlsrv.so: cannot open shared object file: No such file or directory), /usr/lib/php/20170718/sqlsrv.so.so (tried:/usr/lib/php/20170718/sqlsrv.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
I don't know if this will be useful for you wight now, but this was useful for me when I was trying to install sqlsrv dricer for php in my CentOS 8
sudo su
curl https://packages.microsoft.com/config/rhel/7/prod.repo > /etc/yum.repos.d/mssql-release.repo
exit
sudo ACCEPT_EULA=Y yum install msodbcsql
sudo yum install unixODBC-devel
yum groupinstall "Development Tools"
sudo yum install php-pear
sudo yum install php-devel
#IF_ERROR:
sudo yum install dnf-plugins-core
sudo yum config-manager --set-enabled powertools
sudo yum install php-devel
#END_IF_ERROR
sudo pecl install sqlsrv pdo_sqlsrv
sudo echo "extension=/usr/lib64/php/modules/sqlsrv.so" >> /etc/php.d/pdo.ini
sudo echo "extension=/usr/lib64/php/modules/pdo_sqlsrv.so" >> /etc/php.d/pdo.ini
Following this steps I execute php -m and I haver sqlsrv and pdo_sqlsrv installed using php 7.2.

PHP Warning: PHP Startup: Unable to load dynamic library 'mcrypt.so'

I am trying to update laravel using composer update on ubuntu 06.04 but everytime i run composer update this warning always comes up.
PHP Warning: PHP Startup: Unable to load dynamic library 'mcrypt.so' (tried: /usr/lib/php/20170718/mcrypt.so (/usr/lib/php/20170718/mcrypt.so: cannot open shared object file: No such file or directory), /usr/lib/php/20170718/mcrypt.so.so (/usr/lib/php/20170718/mcrypt.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
Does anyone knows how to deal it?
I am using php7.2
I faced similar issue when I installed Php7.2 on Ubuntu 18. Though I had installed mcrypt using PECL still I get the error mentioned in the question.
I did following to fix it
sudo apt-get install php-pear php7.2-dev
then uninstalled
pecl uninstall mcrypt
Now reinstall mcrypt
sudo apt-get -y install gcc make autoconf libc-dev pkg-config
sudo apt-get -y install libmcrypt-dev
sudo pecl install mcrypt-1.0.1
When you are shown the prompt
libmcrypt prefix? [autodetect] :
Press [Enter] to autodetect.
After success installing mcrypt using pecl, you should add mcrypt.so extension to php.ini.
The output will look like this:
...
Build process completed successfully
Installing '/usr/lib/php/20170718/mcrypt.so' ----> this is our path to mcrypt extension lib
install ok: channel://pecl.php.net/mcrypt-1.0.1
configuration option "php_ini" is not set to php.ini location
You should add "extension=mcrypt.so" to php.ini
Now restart Apache
sudo service apache2 restart
Grab installing path and add to cli and apache2 php.ini configuration.
sudo bash -c "echo extension=/usr/lib/php/20170718/mcrypt.so > /etc/php/7.2/cli/conf.d/mcrypt.ini"
sudo bash -c "echo extension=/usr/lib/php/20170718/mcrypt.so > /etc/php/7.2/apache2/conf.d/mcrypt.ini"
First, open up a terminal window and install the necessary dependencies with the commands:
sudo apt-get -y install gcc make autoconf libc-dev pkg-config
sudo apt-get -y install php7.2-dev
sudo apt-get -y install libmcrypt-dev
Once the dependencies have been installed, you can install mcrypt with the command:
sudo pecl install mcrypt-1.0.1
And there you go. Mcrypt is now installed. Go back to the process of installing whatever server software that depends upon this extension and you should be good to go.
For (>= PHP 7.3) you can use the following command:
sudo pecl install mcrypt-1.0.2
I faced this problem when I upgraded my PHP to 7.3
I found mcrypt.so was still present in /etc/php/7.3 that should not be as it is deprecated in php 7.3 so just deleting mcrypt.so from /etc/php/7.3 solved issue.
I used following commands:
cd /etc/php/7.3
sudo rm -rf mcrypt.so
sudo service apache2 restart
İts is worked for me.
export LC_ALL="C"
export LANG="C
sudo pecl install mcrypt-1.0.1
Also, if you're using php 7.2 & are getting this error and you know do not want/need mcrypt, but do not know how to exclude it.... You need edit your php.ini file and either comment this out by using a semi-colon in front of it:
; extension=mcrypt.so
or just delete that line entirely.

Docker PHP5.6 Call to undefined function bindtextdomain()

Problem:
I have a Docker compose with an nginx service and a PHP service.
When I try to open a page of my dev project, I encounter this error:
Fatal error: Call to undefined function bindtextdomain() in /usr/share/nginx/html/some_project/some_path/Bootstrap.php on line 16
I saw that is a problem of a missing dependency: php-gettext.
My configuration:
In my Dockerfile, I try to install it:
FROM php:5.6.30-fpm
MAINTAINER DarckCrystale "xxx#xxx.xx"
# Here I try to install the php-gettext extension
# but it does not work
RUN apt-get update && apt-get install -y php-gettext gettext
# Setup PHP configuration
ADD php.ini /usr/local/etc/php/conf.d/php.ini
In my php.ini, I load it:
extension=gettext.so
Other information:
When I run in my container
php -i | grep extension_dir
I have this message displayed:
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20131226/gettext.so' - /usr/local/lib/php/extensions/no-debug-non-zts-20131226/gettext.so: cannot open shared object file: No such file or directory in Unknown on line 0
What it seems to be to me:
I think
RUN apt-get update && apt-get install -y php-gettext gettext
does not install the php-gettext extension. I don't know why. I think this is a PHP Dockerized specific problem.
So, after struggle, I finally found how to install this extension in the PHP container!
How to solve this problem?
Use docker-php-ext-install instead of apt-get install in the Dockerfile:
FROM php:5.6.30-fpm
MAINTAINER DarckCrystale "xxx#xxx.xx"
# Here I install the php-gettext extension
# and it works! :D
RUN docker-php-ext-install gettext
# Setup PHP configuration
ADD php.ini /usr/local/etc/php/conf.d/php.ini
What is the problem?
PHP container have a specific way to install PHP extensions:
How to install more PHP extensions
We provide the helper scripts docker-php-ext-configure, docker-php-ext-install, and docker-php-ext-enable to more easily install PHP extensions.
So php-gettext extension installation seems to work only using provided scripts.

Error while installing mongo driver for PHP on amazon linux

I tried to install the mongodb driver for PHP on Amazon Linux.
While running sudo pecl install mongo, I get the error message:
fatal error: openssl/evp.h: No such file or directory
#include <openssl/evp.h>
^
compilation terminated.
make: *** [io_stream.lo] Error 1
ERROR: `make' failed
PEAR Version: 1.9.5
PHP Version: 5.3.29
I installed gcc which helped me progress further with the install till this error.
The best Guide I was able to find was here:
http://jonathanhui.com/install-mongodb-amazon-linux
PHP's guide: http://php.net/manual/en/mongo.installation.php
evp is high-level cryptographic functions.
Try to install development libraries:
Ubuntu:
sudo apt-get install libssl-dev
CentOS:
yum install openssl-devel
The right package to install is not libssl-dev but
sudo apt-get install pkg-config
and now you can execute
sudo pecl install mongodb
Don't forget to add extension=mongodb.so to your php.ini file.
To know which php.ini file is loaded you can create and simple php file on vps
<?php
php_info()
?>
Example directory php.ini in phpinfo()

Categories