PDO drivers missing on Ubuntu 16.04 with PHP 7.2.4 - php

I wanted to try the latest version of PHP on Kubuntu 16.04, since then, it seems I can't use pdo with mysql.
When I launch php, I have the following warning:
PHP Warning: PHP Startup: Unable to load dynamic library 'pdo_mysql' (tried: /usr/lib/php/20170718/pdo_mysql (/usr/lib/php/20170718/pdo_mysql: cannot open shared object file: No such file or directory), /usr/lib/php/20170718/pdo_mysql.so (/usr/lib/php/20170718/pdo_mysql.so: undefined symbol: pdo_parse_params)) in Unknown on line 0
I'm running
PHP 7.2.4-1+ubuntu16.04.1+deb.sury.org+1 (cli) (built: Apr 5 2018 08:53:57) ( NTS )
I tried to fix with this solution : https://askubuntu.com/a/824505, but I've the same problem.
However, in the phpinfo, there's a driver found for PDO (mysql).
When I check a php -m, PDO and pdo_mysql are found.
In the /usr/lib/php/20170718 and /usr/lib/php/20151012 folder, there is a pdo_mysql.so.
I don't really know what else to try. Thanks in advance for your help.

sudo apt-get update
sudo apt-get install php7.2-pdo

In my case I had updated from Ubuntu 16.04 to 18.04, thus PHP 7.0 to 7.2.
Turns out PHP 7.0 was still (partly) installed, and was the active PHP-FPM handler for Apache.
Commands I used to resolve this: (as root or via sudo)
service php7.0-fpm stop
apt-get remove php7.0*
service php7.2-fpm restart
service apache2 restart
Be sure to copy any INI changes you made from /etc/php/7.0 to /etc/php/7.2 though.

Related

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

Has anyone come across this warning before? Any files I should check other than php.ini or 00-ioncube.ini? Those look to be in good order.
$ php -v
PHP Warning: PHP Startup: Unable to load dynamic library 'imagick.so' (tried: /usr/lib64/php/modules/imagick.so (libMagickWand.so.5: cannot open shared object file: No such file or directory), /usr/lib64/php/modules/imagick.so.so (/usr/lib64/php/modules/imagick.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
PHP 7.3.31 (cli) (built: Sep 21 2021 10:24:03) ( NTS )
Operating System:
Operating System: CentOS Linux 7 (Core)
CPE OS Name: cpe:/o:centos:centos:7
Kernel: Linux 3.10.0-1160.42.2.el7.x86_64
Architecture: x86-64
I upgraded PHP from version 7.1 to 7.3 on using these steps:
php -v
sudo yum install epel-release
yum --enablerepo=remi-php73 install php
php -v
systemctl restart httpd
I only see one php.ini file loaded in /etc/
Check how was the imagick extension was installed:
rpm -qf /usr/lib64/php/modules/imagick.so
It looks like it is not provided by a RPM, nor built for the proper PHP version you are running (libMagickWand.so.5 is also an old version).
For a proper configuration / installation, see the Wizard instructions
At least I recommend you enable the remi-php73 repository permanently, to ensure all extensions are taken from it.
yum-config-manager --enable remi-php73
Then you can install the imagick extension, or any other extension you need
yum install php-imagick
Notice, in this repository you have the choice between 2 variants of this extension, above command will pick one among:
php-pecl-imagick-im6 build with ImageMagick version 6 (libMagickCore-6.Q16.so.7, libMagickWand-6.Q16.so.7)
php-pecl-imagick-im7 build with ImageMagick version 7 (libMagickCore-7.Q16HDRI.so.10, libMagickWand-7.Q16HDRI.so.10)
APIs are slightly different.

Woo commerce Error: How to enable soap client on debian server?

I have deployed WordPress on debian VM on GCP.
I am getting an error:
Your server does not have the SoapClient class enabled - some gateway plugins which use SOAP may not work as expected.
I have run below commands to install soap client:
sudo apt-get install php-soap
After installation, it is still same showing same error.
When I checked the php version, it shows below warning
PHP Warning: PHP Startup: Unable to load dynamic library 'soap' (tried: /usr/lib/php/20190902/soap (/usr/lib/php/20190902/soap: cannot open shared object file: No such file or directory), /usr/lib/php/20190902/soap.so (/usr/lib/php/20190902/soap
.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
What to do to remove this error?
Seems to be that the php7.3-soap package is corrupted, please try reinstalling it and after that restart the Apache service, then validate the error is no longer present.
$ sudo apt-get reinstall php7.3-soap
$ php -m | grep soap
$ php -v
Please note that Debian 10 (buster) default Php version is 7.3.

PHP Startup: Unable to load dynamic library 'pdo_mysql' in linux mint 20.2 PHP8 [duplicate]

root#ip-10-131-9-200:/etc/php5/apache2# php -a
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20090626+lfs/curl.so' - /usr/lib/php5/20090626+lfs/curl.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20090626+lfs/mcrypt.so' - /usr/lib/php5/20090626+lfs/mcrypt.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20090626+lfs/mysql.so' - /usr/lib/php5/20090626+lfs/mysql.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20090626+lfs/mysqli.so' - /usr/lib/php5/20090626+lfs/mysqli.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20090626+lfs/pdo.so' - /usr/lib/php5/20090626+lfs/pdo.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20090626+lfs/pdo_mysql.so' - /usr/lib/php5/20090626+lfs/pdo_mysql.so: cannot open shared object file: No such file or directory in Unknown on line 0
Interactive shell
Even though several other answers suggest it, installing more unnecessary software is generally not the best solution. Instead, you should fix the underlying problem. The reason these messages appear is because you are trying to load those extensions, but they are not installed. So the easy solution is simply to tell PHP to stop trying to load them:
First, find out which files are trying to load the above extensions:
$ grep -Hrv ";" /etc/php5 | grep -E "extension(\s+)?="
Example output for Ubuntu:
/etc/php5/mods-available/gd.ini:extension=gd.so
/etc/php5/mods-available/pdo_sqlite.ini:extension=pdo_sqlite.so
/etc/php5/mods-available/pdo.ini:extension=pdo.so
/etc/php5/mods-available/pdo_mysql.ini:extension=pdo_mysql.so
/etc/php5/mods-available/mysqli.ini:extension=mysqli.so
/etc/php5/mods-available/mysql.ini:extension=mysql.so
/etc/php5/mods-available/curl.ini:extension=curl.so
/etc/php5/mods-available/sqlite3.ini:extension=sqlite3.so
/etc/php5/conf.d/mcrypt.ini:extension=mcrypt.so
/etc/php5/conf.d/imagick.ini:extension=imagick.so
/etc/php5/apache2/php.ini:extension=http.so
Now just find the files that are loading the extensions that are causing the errors and comment out those lines with a ;. For some reason this happened to me with the default install of Ubuntu, so hopefully this helps someone else.
sudo apt-get install php5-mcrypt
sudo apt-get install php5-mysql
...etc resolved it for me :)
hope it helps
Look /etc/php5/cli/conf.d/ and delete corresponding *.ini files. This error happens when you remove some php packages not so cleanly.
Seems like you upgraded PHP to newer version and old .ini files are still pointing to old location.
The solution: find out where are modules located now
ls -l /usr/lib/php5
There should be a directory similar to old 20090626. In my case it is now 20131226
The .ini files giving you an error are located at /etc/php5/cli/conf.d/
Just edit those .ini files which module gives you an error. For example, in case the error is for mcrypt module:
sudo vi /etc/php5/cli/conf.d/20-mcrypt.ini
Change the line:
extension=/usr/lib/php5/20090626/mcrypt.so
to reflect the new path for .so file. In my case the correct path should be:
extension=/usr/lib/php5/20131226/mcrypt.so
That's it! The error is gone. Ofc you'd have to do it with each module giving you an error.
If you put the ; symbol, this action inactive the extension.
I had the same problem and did the following:
Uninstall php with purge parameter:
sudo apt-get --purge remove php5-common
And install again:
sudo apt-get install php5 php5-mysql
My problem was solved by the following command
sudo apt-get install php5-mcrypt
I have
PHP 5.3.10-1ubuntu3.4 with Suhosin-Patch (cli)
Ubuntu Desktop 12.04
Mysql 5.5
I found this solution by blog.tordeu.com, and it's
sudo aptitude purge php5-suhosin
I'm not sure, but it seems that the suhosin is no longer needed, it worked for my, my PHP version:
PHP 5.4.34-1+deb.sury.org~lucid+1 (cli) (built: Oct 17 2014 15:26:51)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2014 Zend Technologies
If you are using 5.6 php,
sudo apt-get install php5.6-curl
Somehow the gmp.so file seems to have been deleted from my system. This is what fixed it for me:
sudo apt-get install --reinstall php5-gmp
Well for Ubuntu 14.04 I was getting that error just for mcrypt:
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20121212/mcrypt.ini' - /usr/lib/php5/20121212/mcrypt.ini: cannot open shared object file: No such file or directory in Unknown on line 0
If you have a closer look at the error, php is looking for mcrypt.ini and not for mcrypt.so at that location. I just copy mcrypt.so to mcrypt.ini and that's it, the warning is gone and the extension now is properly installed. It might look a bit dirty but it worked!
I had enabled the extension_dir in php.ini by uncommenting,
extension_dir = "ext"
extension=phpchartdir550.dll
and copying phpchartdir550 dll to the extension_dir (/usr/lib/php5/20121212), resulted in the same error.
PHP Warning: PHP Startup: Unable to load dynamic library 'ext/phpchartdir550.dll' - ext/phpchartdir550.dll: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library 'ext/pdo.so' - ext/pdo.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library 'ext/gd.so' - ext/gd.so: cannot open shared object file: No such file or directory in Unknown on line 0
As #Mike pointed out, it is not necessary to install all the stuff when they are not actually required in the application.
The easier way is to provide the full path to the extensions to be loaded after copying the libraries to the correct location.
Copy phpchartdir550.dll to /usr/lib/php5/20121212, which is the extension_dir in my Ubuntu 14.04 (this can be seen using phpinfo())
and then provide full path to the library in php.ini,
; extension=/path/to/extension/msql.so
extension=/usr/lib/php5/20121212/phpchartdir550.dll
restart apache: sudo service apache2 restart
even though other .so's are present in the same directory, only the required ones can be selectively loaded.
I had a similar problem, which led me here:
$ phpunit --version
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20131226/profiler.so' - /usr/lib/php5/20131226/profiler.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHPUnit 5.7.17 by Sebastian Bergmann and contributors.
Unlike the above, installing the software did not resolve my problem because I already had it.
$ sudo apt-get install php5-uprofiler
Reading package lists... Done
Building dependency tree
Reading state information... Done
php5-uprofiler is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 52 not upgraded.
I found my solution via : Debian Bug report logs
$ sudo vim /etc/php5/mods-available/uprofiler.ini
I edited the ini file, changing extension=profiler.so to extension=uprofiler.so .... the result, happily:
$ phpunit --version
PHPUnit 5.7.17 by Sebastian Bergmann and contributors.
i.e. no more warning.
(For Ubuntu users)
I had the same problem, but none of the answers above solved that. Here is how I solved the problem.
Open your php.ini file (mine was in /etc/php/7.3/cli/php.ini).
You may have something like this:
extension=pdo_mysql
Or maybe:
extension=/here/is/the/path/to/your/file/pdo_mysql.so
Add the following line before extension=pdo_mysql
extension=pdo
So, you will have:
extension=pdo
extension=pdo_mysql
It seems that the problem is (at least in my case) that we need to load pdo extension first to load the pdo_mysql extension.
Hope that helps!

Unable to load dynamic library 'pdo_mysql' [duplicate]

root#ip-10-131-9-200:/etc/php5/apache2# php -a
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20090626+lfs/curl.so' - /usr/lib/php5/20090626+lfs/curl.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20090626+lfs/mcrypt.so' - /usr/lib/php5/20090626+lfs/mcrypt.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20090626+lfs/mysql.so' - /usr/lib/php5/20090626+lfs/mysql.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20090626+lfs/mysqli.so' - /usr/lib/php5/20090626+lfs/mysqli.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20090626+lfs/pdo.so' - /usr/lib/php5/20090626+lfs/pdo.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20090626+lfs/pdo_mysql.so' - /usr/lib/php5/20090626+lfs/pdo_mysql.so: cannot open shared object file: No such file or directory in Unknown on line 0
Interactive shell
Even though several other answers suggest it, installing more unnecessary software is generally not the best solution. Instead, you should fix the underlying problem. The reason these messages appear is because you are trying to load those extensions, but they are not installed. So the easy solution is simply to tell PHP to stop trying to load them:
First, find out which files are trying to load the above extensions:
$ grep -Hrv ";" /etc/php5 | grep -E "extension(\s+)?="
Example output for Ubuntu:
/etc/php5/mods-available/gd.ini:extension=gd.so
/etc/php5/mods-available/pdo_sqlite.ini:extension=pdo_sqlite.so
/etc/php5/mods-available/pdo.ini:extension=pdo.so
/etc/php5/mods-available/pdo_mysql.ini:extension=pdo_mysql.so
/etc/php5/mods-available/mysqli.ini:extension=mysqli.so
/etc/php5/mods-available/mysql.ini:extension=mysql.so
/etc/php5/mods-available/curl.ini:extension=curl.so
/etc/php5/mods-available/sqlite3.ini:extension=sqlite3.so
/etc/php5/conf.d/mcrypt.ini:extension=mcrypt.so
/etc/php5/conf.d/imagick.ini:extension=imagick.so
/etc/php5/apache2/php.ini:extension=http.so
Now just find the files that are loading the extensions that are causing the errors and comment out those lines with a ;. For some reason this happened to me with the default install of Ubuntu, so hopefully this helps someone else.
sudo apt-get install php5-mcrypt
sudo apt-get install php5-mysql
...etc resolved it for me :)
hope it helps
Look /etc/php5/cli/conf.d/ and delete corresponding *.ini files. This error happens when you remove some php packages not so cleanly.
Seems like you upgraded PHP to newer version and old .ini files are still pointing to old location.
The solution: find out where are modules located now
ls -l /usr/lib/php5
There should be a directory similar to old 20090626. In my case it is now 20131226
The .ini files giving you an error are located at /etc/php5/cli/conf.d/
Just edit those .ini files which module gives you an error. For example, in case the error is for mcrypt module:
sudo vi /etc/php5/cli/conf.d/20-mcrypt.ini
Change the line:
extension=/usr/lib/php5/20090626/mcrypt.so
to reflect the new path for .so file. In my case the correct path should be:
extension=/usr/lib/php5/20131226/mcrypt.so
That's it! The error is gone. Ofc you'd have to do it with each module giving you an error.
If you put the ; symbol, this action inactive the extension.
I had the same problem and did the following:
Uninstall php with purge parameter:
sudo apt-get --purge remove php5-common
And install again:
sudo apt-get install php5 php5-mysql
My problem was solved by the following command
sudo apt-get install php5-mcrypt
I have
PHP 5.3.10-1ubuntu3.4 with Suhosin-Patch (cli)
Ubuntu Desktop 12.04
Mysql 5.5
I found this solution by blog.tordeu.com, and it's
sudo aptitude purge php5-suhosin
I'm not sure, but it seems that the suhosin is no longer needed, it worked for my, my PHP version:
PHP 5.4.34-1+deb.sury.org~lucid+1 (cli) (built: Oct 17 2014 15:26:51)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2014 Zend Technologies
If you are using 5.6 php,
sudo apt-get install php5.6-curl
Somehow the gmp.so file seems to have been deleted from my system. This is what fixed it for me:
sudo apt-get install --reinstall php5-gmp
Well for Ubuntu 14.04 I was getting that error just for mcrypt:
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20121212/mcrypt.ini' - /usr/lib/php5/20121212/mcrypt.ini: cannot open shared object file: No such file or directory in Unknown on line 0
If you have a closer look at the error, php is looking for mcrypt.ini and not for mcrypt.so at that location. I just copy mcrypt.so to mcrypt.ini and that's it, the warning is gone and the extension now is properly installed. It might look a bit dirty but it worked!
I had enabled the extension_dir in php.ini by uncommenting,
extension_dir = "ext"
extension=phpchartdir550.dll
and copying phpchartdir550 dll to the extension_dir (/usr/lib/php5/20121212), resulted in the same error.
PHP Warning: PHP Startup: Unable to load dynamic library 'ext/phpchartdir550.dll' - ext/phpchartdir550.dll: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library 'ext/pdo.so' - ext/pdo.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library 'ext/gd.so' - ext/gd.so: cannot open shared object file: No such file or directory in Unknown on line 0
As #Mike pointed out, it is not necessary to install all the stuff when they are not actually required in the application.
The easier way is to provide the full path to the extensions to be loaded after copying the libraries to the correct location.
Copy phpchartdir550.dll to /usr/lib/php5/20121212, which is the extension_dir in my Ubuntu 14.04 (this can be seen using phpinfo())
and then provide full path to the library in php.ini,
; extension=/path/to/extension/msql.so
extension=/usr/lib/php5/20121212/phpchartdir550.dll
restart apache: sudo service apache2 restart
even though other .so's are present in the same directory, only the required ones can be selectively loaded.
I had a similar problem, which led me here:
$ phpunit --version
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20131226/profiler.so' - /usr/lib/php5/20131226/profiler.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHPUnit 5.7.17 by Sebastian Bergmann and contributors.
Unlike the above, installing the software did not resolve my problem because I already had it.
$ sudo apt-get install php5-uprofiler
Reading package lists... Done
Building dependency tree
Reading state information... Done
php5-uprofiler is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 52 not upgraded.
I found my solution via : Debian Bug report logs
$ sudo vim /etc/php5/mods-available/uprofiler.ini
I edited the ini file, changing extension=profiler.so to extension=uprofiler.so .... the result, happily:
$ phpunit --version
PHPUnit 5.7.17 by Sebastian Bergmann and contributors.
i.e. no more warning.
(For Ubuntu users)
I had the same problem, but none of the answers above solved that. Here is how I solved the problem.
Open your php.ini file (mine was in /etc/php/7.3/cli/php.ini).
You may have something like this:
extension=pdo_mysql
Or maybe:
extension=/here/is/the/path/to/your/file/pdo_mysql.so
Add the following line before extension=pdo_mysql
extension=pdo
So, you will have:
extension=pdo
extension=pdo_mysql
It seems that the problem is (at least in my case) that we need to load pdo extension first to load the pdo_mysql extension.
Hope that helps!

PHP7.0 - unable to load dynamic library oci8.so (Ubuntu)

After following the install instructions for oracle instant client, php is not able to load the oci8 extension.
http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html#ic_x64_inst
I am getting an error.
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/20151012/oci8.so' - libmql1.so: cannot open shared object file: No such file or directory in Unknown on line 0
I have verified both oci8.so and libmql1.so locations.
Am I missing something?
I'm using Ubuntu 16.04 and php version 7.1
There are few directories in /usr/lib/php/
for example
20131226 for php5.6
20160303 for php7.1
so problem with me that, the oci8 extension got installed on the wrong ( a user lib folder for php7.2) so I had to remove the php 7.2 completly
sudo apt-get purge php7.2-common
then I had uninstall the oci8 by running following command
sudo pecl uninstall oci8
and install again by running the following command
sudo pecl install oci8
To check the configuration loaded you do
php-config --extension-dir
And make sure that all extension are installed in the correct extension directory.
Make changes in the /etc/php/7.1/apache2/php.ini and /etc/php/7.1/cli/php.ini
Check by running phpinfo(); You must see this, ignore the cli if that stills gives you same error as your web shows the extension is getting loaded.
I solved adding the following to /etc/environment:
LD_LIBRARY_PATH=/opt/oracle/instantclient_12_2:$LD_LIBRARY_PATH
I followed this tutorial: https://gist.github.com/hewerthomn/81eea2935051eb2500941a9309bca703
What I did was completely remove any installations of PHP and reinstall the version that I need.
sudo apt-get purge 'php*'
Source: https://askubuntu.com/a/59889/226518
Or:
export LD_LIBRARY_PATH=/usr/local/instantclient_12_1/
I had the same problem, it works for me.
After wasting entire day for this small problem finally I came with this solution.
Sorry guys I am not champion is PHP but somehow I manage.
In my system I have CentOS 7 and PHP 7.4.XX.
I changed my LD_LIBRARY_PATH,
I have restarted my httpd service and checked phpinfo in browser (http://localhost/info.php),
Last I restared php-fpm service ........... and it's work for me.
Thanking you,
Anand

Categories