PHP unable to load dynamic library (mongo.so) - php

i'm trying to use rockmongo. After installation, i'm unable to use it. It says "To make things right, you must install php_mongo module. Here for installation documents on PHP.net."
i have already installed mongoDB driver extension via sudo pecl install mongo.
locate mongo shows /usr/lib/php5/20090626+lfs/mongo.so
However, php -v shows few warnings (which i think is related to mongo)
PHP: syntax error, unexpected $end, expecting ']' in /etc/php5/cli/conf.d/mongodb.ini on line 3
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20100525+lfs/mongo.so' - /usr/lib/php5/20100525+lfs/mongo.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP 5.4.28-1+deb.sury.org~precise+1 (cli) (built: May 5 2014 09:39:26)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2014 Zend Technologies
i opened /usr/lib/php5/ and found out that there are another directory(20090626+lfs) which contains mongo.so.
i tried various online tutorial, but nothing helped.
Edit: Here's my mongodb.ini
;----- start -----
extension=mongo.so
\[mongo\]
; If the driver should reconnect to mongo
mongo.auto_reconnect = true
; Whether to allow persistent connections
mongo.allow_persistent = On
; Maximum number of persistent connections (-1 means unlimited)
mongo.max_persistent = -1
; Maximum number of links (persistent and non-persistent, -1 means unlimited)
mongo.max_connections = -1
; Default host for mongo connection
mongo.default_host = www.example.com
; Default port for mongo database
mongo.default_port = 42
; When saving files to the database, size of chunks to split them into
mongo.chunk_size = 1024
; Specify an alternate character to $ to use for special db functions ($set, $push, $exists, etc.)
mongo.cmd = "$"
;----- end -----

I solved this problem using the 1.1.9 version of mongodb driver for php 5. First uninstall the current version of mongodb and then install the 1.1.9 version:
sudo pecl uninstall mongodb
sudo pecl install mongodb-1.1.9
composer update

My php version is 7.0, but it should work version 5.x too.
If you have this in the file /etc/php/7.0/mods-available/mongo.ini
extension=mongodb.so
Comment that line. After that restart php and it should work.

For me this works well
sudo apt-get install php7.2-mongodb
Change the '7.2' for your php version

Add the full path to your mongo.so extension in mongodb.ini:
extension=/usr/lib/php5/20090626+lfs/mongo.so
Also the [mongo] should be written exactly like that NOT \[mongo\].
Don't forget to reload/restart your web server to load the new configuration.
You can check that everything is ok with:
php -i | grep mongo

After OS update, I had a similar error while running any PHP CLI, simply running "php -v" produced the error:
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/20131226/mongodb.so'
I checked the folder, I found the file '/usr/lib/php/20131226/mongodb.so' existed. So, I simply commented on the line "extension=mongo.so" in '/etc/php/5.6/cli/php.ini' file. It fixed my issue.
When checked mongo --version, it was working fine.

Related

Running yii php project, getting Invalid Configuration error

I am trying to run a yii project which I copied from server. The project is running fine on live server.
I installed wamp for that purpose, and using composer installed all packages. The project is using advanced yii template, when I goto http://localhost/nz-tool.nztours.de/backend/web/ to run backend index page. I get the following error
Invalid Configuration – yii\base\InvalidConfigException MemCache
requires PHP memcache extension to be loaded.
Btw I am new to yii and php, so I maybe missing some configuration. Upon googling I found out that php_memcached.dll dll is missing. I copied and put it in the right folder C:\wamp64\bin\php\php7.4.26\ext and updated php.ini, even tried changing php versions. But still memCached dll is not loading.
When I run php --version, it complains of missing php_memCached.dll file.
Warning: PHP Startup: Unable to load dynamic library 'php_memcached.dll' (tried: c:/wamp64/bin/php/php7.4.26/ext/php_memcached.dll (The specified module could not be found.), c:/wamp64/bin/php/php7.4.26/ext/php_php_memcached.dll.dll (The specified module could not be found.)) in Unknown on line 0
PHP 7.4.26 (cli) (built: Nov 16 2021 18:15:31) ( ZTS Visual C++ 2017 x64 )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
I also followed this guide to install memcache service.
Additional info:
I have tried xamp and still same issue.
Please check if you copied the memcached DLL file to the correct location.
Your PHP warning says something about
c:/wamp64/bin/php/php7.4.26/ext/php_php_memcached.dll.dll
and looked for
c:/wamp64/bin/php/php7.4.26/ext/php_memcached.dll
and in php.ini file, these configurations need to be set
extension=php_memcache.dll
[Memcache]
memcache.allow_failover = 1
memcache.max_failover_attempts=20
memcache.chunk_size =8192
memcache.default_port = 11211

PHP 7.4 and Ubuntu 18 - PHP Startup: Unable to load dynamic library 'curl.so'

I'm using the ondrej ppa for PHP and am running Ubuntu 18. Running php -v gives me the following output:
PHP Warning: PHP Startup: Unable to load dynamic library 'curl.so' (tried: /usr/lib/php/20190902/curl.so (/usr/lib/php/20190902/curl.so: symbol curl_mime_addpart version CURL_OPENSSL_4 not defined in file libcurl.so.4 with link time reference), /usr/lib/php/20190902/curl.so.so (/usr/lib/php/20190902/curl.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
PHP 7.4.2 (cli) (built: Jan 23 2020 11:21:30) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Zend OPcache v7.4.2, Copyright (c), by Zend Technologies
Basically, I can't run any composer commands because a lot of libraries depend on curl, and apparently it isn't being found. I've done the following:
Tried to update everything (sudo apt-get update && sudo apt-get upgrade && sudo apt-get dist-upgrade && sudo apt-get install php7.4-curl). This doesn't fix the issue.
Restarted apache despite this being the cli version.
Double checked where it's trying to find the library. What's weird is that /usr/lib/php/20190902/curl.so is a valid path and the file is definitely there.
Running php --ini also shows that the curl extension is loaded:
Configuration File (php.ini) Path: /etc/php/7.4/cli
Loaded Configuration File: /etc/php/7.4/cli/php.ini
Scan for additional .ini files in: /etc/php/7.4/cli/conf.d
Additional .ini files parsed: /etc/php/7.4/cli/conf.d/10-mysqlnd.ini,
...more ini files...
/etc/php/7.4/cli/conf.d/20-curl.ini,
...more ini files...
I'm unsure how to fix this as the file it supposedly can not find is exactly where it says it looked, and everything is up to date.
For anyone with this issue, the answer is here.
Basically, the libcurl that was installed on my Ubuntu machine clashed with the official one that Ubuntu has? Weirdly it was only affecting php7.3 and 7.4 and not 7.2. Anyways, I renamed the libcurl module like so:
mv /usr/local/lib/libcurl.so.4.4.0 /usr/local/lib/libcurl.so.4.4.0.backup
And by running php -m, I could verify that the cURL module was now enabled.
I found that if I did:
apt search | more
(the pipe is for long lists)
that I could find the php package name that I needed.
For example:
apt search curl
told me that the name of the package for my php version is 'php7.2-curl'
So, all I had to do was sudo apt install php7.2 curl.
I repeated this (some names require a little googling, and/or some apt search creativity.
I solved it by doing this:
Uninstall curl:
apt remove php7.4-curl
New install:
apt install php7.4-curl
I have now all right.
After trying to run composer update things were failing because the deps where from php -v 7 while I was using 8.
composer install --ignore-platform-reqs
worked for me

"Unable to load dynamic library 'pdo_sqlsrv.so' "Cenos7 PHP7.2.10

I have overlook at this issue Linux - PHP 7.0 and MSSQL (Microsoft SQL)
and I am sure did exactly what MS told me to do in this page
installing-the-drivers-on-red-hat-7
howevey, i stiil got the error when type 'php -v':
PHP Warning: PHP Startup: Unable to load dynamic library
'pdo_sqlsrv.so' (tried: /usr/lib64/php/modules/pdo_sqlsrv.so
(/usr/lib64/php/modules/pdo_sqlsrv.so: undefined symbol:
php_pdo_register_driver), /usr/lib64/php/modules/pdo_sqlsrv.so.so
(/usr/lib64/php/modules/pdo_sqlsrv.so.so: cannot open shared object
file: No such file or directory)) in Unknown on line 0
PHP 7.2.10
(cli) (built: Sep 15 2018 07:10:58) ( NTS ) Copyright (c) 1997-2018
The PHP Group Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend
Technologies
with Zend OPcache v7.2.10, Copyright (c) 1999-2018, by Zend
Technologies
I never modify the php.ini,
[user#tssvr php.d]$ pwd
/etc/php.d
[user#tssvr php.d]$ ls
20-sqlsrv.ini ctype.ini fileinfo.ini gmp.ini mbstring.ini pdo.ini shmop.ini tokenizer.ini xmlwriter.ini
30-pdo_sqlsrv.ini curl.ini ftp.ini iconv.ini mysqli.ini pdo_mysql.ini simplexml.ini xml.ini xsl.ini
bz2.ini dom.ini gd.ini intl.ini opcache-default.blacklist pdo_sqlite.ini sockets.ini xmlreader.ini zip.ini
calendar.ini exif.ini gettext.ini json.ini opcache.ini phar.ini sqlite3.ini xml_wddx.ini
[user#tssvr php.d]$ cat 20-sqlsrv.ini
extension=sqlsrv.so
[user#tssvr php.d]$ cat 30-pdo_sqlsrv.ini
extension=pdo_sqlsrv.so
it seems that the sqlsrv.so is good, but the pho_sqlsrv.so just can't work correctly,,although i notice that double 'so' appear: 'pdo_sqlsrv.so.so' ,
can any guys can help me through this ,many thanks.
Type in terminal linux centos 7 :
php --ini
find /etc/php.d/20-pdo.ini
Edit the file and append extension=sqlsrv.so extension=pdo_sqlsrv.so
note: comment extension extension=sqlsrv.so , extension=pdo_sqlsrv.so in /etc/php.ini
reboot system
php -m - you see loaded module
The proper order to load the modules is:
extension=pdo.so
extension=pdo_sqlsrv.so
extension=sqlsrv.so
One can either put these into one .ini file - or use numbered .ini files.
Loading them in alphabetical order (which is the default) won't work.
I ran into the same issue with Ubuntu 18.04 and 20.xx. I finally got it to work on Ubuntu 18.04 and pretty sure this will work on 20.xx as well.
This is for PHP 7.1 so if you are not using 7.4 or 8.0 you will have to specify the version in pecl.
pecl install sqlsrv-5.7.0preview
pecl install pdo_sqlsrv-5.7.0preview
printf "; priority=20\nextension=sqlsrv.so\n" > /etc/php/7.1/mods-available/sqlsrv.ini
printf "; priority=30\nextension=pdo_sqlsrv.so\n" > /etc/php/7.1/mods-available/pdo_sqlsrv.ini
phpenmod -v 7.1 sqlsrv pdo_sqlsrv
service apache2 restart
The trick that got everything working was the printf and phpenmod command. You still need to add the extension to your php.ini file as well. Not sure if the order really matters but the driver does not appear to get installed properly using the pecl installer.
After restarting apache I can now see pdo_sqlsrv listed in php.ini and my php application can connect to the local Microsoft SQL server.
BTW, I got this working on WSL2 for Windows.
This is the way I solved this on CentOS 7.
First I've installed pdo_dblib extension
[root#localhost html]# yum list *dblib*
Complementos cargados:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirror.airenetworks.es
* centos-sclo-rh: mirror.airenetworks.es
* epel: ftp.uma.es
* extras: mirror.airenetworks.es
* remi-safe: mir01.syntis.net
* updates: mirror.tedra.es
Paquetes instalados
php73-php-pdo-dblib.x86_64
Paquetes disponibles
php70-php-pdo-dblib.x86_64
php71-php-pdo-dblib.x86_64
php72-php-pdo-dblib.x86_64
php74-pdo-dblib.x86_64
php74-php-pdo-dblib.x86_64
php80-php-pdo-dblib.x86_64
php81-php-pdo-dblib.x86_64
[root#localhost html]# yum install php73-php-pdo-dblib.x86_64
I have php 7.3 installed so I've chosen matching version extension. After installation, tried a simple test script I created to test connectivity but still got error.
Used locate command to find out if pdo_dblib.so library was correctly installed and found it under /opt/remi/php73/root/usr/lib64/php/modules path which looked a bit strange
With the command locate php.ini I discovered that there were 2 php.ini files on the machine. With the command php -i and by creating a simple file to test it from the web browser:
<?php
phpinfo()
I checked what php.ini file was in use both from Cli and from Apache. It was /etc/php.ini.
With php -m I saw PDO was loading correctly, so I searched the location of pdo.so library. Copied pdo_dblib.so library on previous search location. Searched for pdo_dblib.ini file and copied it under the location of pdo.ini file (which full name was 20-pdo.ini).
After all of these changes, restarted Apache systemctl restart httpd and checked again that pdo_dblib was loading both from cli and web whith php -i and the phpinfo() file.

PHP, Apache: Unable to load dynamic library (even if there is one)

Today I have migrated my XAMPP's internals to 64bit:
Apache (from 32bit 2.4.25 to 64bit 2.4.27)
PHP (from 32bit 7.1.4 to 64bit 7.1.9)
I have downloaded each extension used before in 32bit, installed, configured (copy&paste mostly with path changes if needed) and generally everything "works".
-> % php --version
PHP 7.1.9 (cli) (built: Aug 30 2017 18:34:46) ( ZTS MSVC14 (Visual C++ 2015) x64 )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
But somehow I get PHP Startup: Unable to load dynamic library errors even if there are valid DLLs (most of them bundled in downloaded PHP package). These are curl, intl, ldap and imagick (the last one is installed by me). Paths are correct in php.ini (many other extensions are loaded properly from the same directory). This is what I get in php_error_log every time when I access page through Apache:
[22-Sep-2017 15:52:47 UTC] PHP Warning: PHP Startup: Unable to load dynamic library 'D:\Bin\XAMPP\7.0.9\php\ext\php_curl.dll' - The specified module could not be found.
in Unknown on line 0
[22-Sep-2017 15:52:47 UTC] PHP Warning: PHP Startup: Unable to load dynamic library 'D:\Bin\XAMPP\7.0.9\php\ext\php_intl.dll' - The specified module could not be found.
in Unknown on line 0
[22-Sep-2017 15:52:47 UTC] PHP Warning: PHP Startup: Unable to load dynamic library 'D:\Bin\XAMPP\7.0.9\php\ext\php_ldap.dll' - The specified module could not be found.
in Unknown on line 0
[22-Sep-2017 15:52:47 UTC] PHP Warning: PHP Startup: Unable to load dynamic library 'D:\Bin\XAMPP\7.0.9\php\ext\php_imagick.dll' - The specified module could not be found.
in Unknown on line 0
In CLI everything is fine (it's the same php.ini as for Apache):
-> % php -i | grep -n3 curl
175:curl
178-cURL Information => 7.55.0
-> % php -i | grep -n3 ldap
347:ldap
349-LDAP Support => enabled
350-RCS Version => $Id: 0779387e5f88edc656159d12b9302a053e82cc79 $
-> % php -i | grep -n3 intl
330:intl
332-Internationalization support => enabled
333-version => 1.1.0
335-ICU Data version => 57.1
but in Apache I have Attempted to call function "curl_init" ... error :(
Any ideas?
I had the same problem on Windows 10 and solved it by adding the php home directory to the system (NOT user!) PATH environment and rebooting the system.
When Apache is installed as a service it is run as a system user which means it does not see your user environment variables.
it's basically 404'ing the dll's. either the user that apache runs as, doesn't have permissions to read the folder D:\Bin\XAMPP\7.0.9\php\ext\ , or the folder doesn't exist. as for why it works in cli but not in apache, they're probably reading different php.ini's , but it could also be that php-cli runs as a different user account. to check that, run php -r 'phpinfo();' | grep -i username in cli, and a page with <?php phpinfo(); and look for "Enviorment" > "User" in apache phpinfo(); , the pages will also tell you if they're loading the same php.ini file.
and nothing of this has anything to do with programming, so i say again, this should be on serverfault.com or something, not stackoverflow.com
Check if your DLL's are in proper version. There is quite often difference between x64 and x86 version, also between ZTS and NON TREAD SAFE. For some reason instead of nice error message of ddls being incompatible you will only get information: cannot load extension.
Well, this is weird but the root problem of this issue was... using Apache as service. I can't explain why, but when running Apache as service these extensions could not be loaded, but when running without service, using only "Start" from XAMPP control center, all is working fine with the same config and directory/file structure.
I realized that when I wanted to back to my previous working versions and I linked 32bit versions again (I use apache and php symlinks in XAMPP installation dir). cURL was not loaded, but it was working before migrating to 64bit. So I started digging and experiment with service and after unregistering it started working correctly. So I thought it could be the case with 64bit too... And it was.
Now I can start Apache properly. There is still minor issue because XAMPP control panel doesn't show Apache as running after clicking "Start", but processes are there and is working. But most important is everything is OK under the hood.
I had the same problem. All extensions loaded except these two: amqp and pdo_sqlite:
PHP Warning: PHP Startup: Unable to load dynamic library 'pdo_sqlite' (tried: D:\\xampp74\\php\\ext\\pdo_sqlite (The specified module could not be found.), D:\\xampp74\\php\\ext\\php_pdo_sqlite.dll (The specified module could not be found.)) in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library 'amqp' (tried: D:\\xampp74\\php\\ext\\amqp (The specified module could not be found.), D:\\xampp74\\php\\ext\\php_amqp.dll (The specified module could not be found.)) in Unknown on line 0
One solution is so add the php path to your environmental variable PATH.
The real problem here is that although extension dlls live in xampp\php\ext, some extensions have additional files that are located in xampp\php. These additional dlls are the ones that can not be loaded if the php path is not added to your PATH.
If you do not want to add the PHP path to your PATH, the solution is to add the extra dll files to the xampp\apache\bin folder (copy, not move). In my case:
libsqlite3.dll for pdo_sqlite
rabbitmq.4.dll and rabbitmq.4.pdb for php_amqp
Or, if you start apache via a batch file, add the php path before starting apache:
SET PATH=%PATH%;d:\xampp74\php

FFMPEG on Fedora but PHP Compilation confliction

I have running Xampp with PHP5.5 on Fedora from Apache Friend, with default settings what the installer package do on Linux.
When I install FFMPEG successfully and try to load from php.ini it always says:
*
11-Oct-2013 14:05:51 Europe/Berlin] PHP Warning: PHP Startup: ffmpeg: Unable to initialize module
Module compiled with module API=20060613
PHP compiled with module API=20121212
These options need to match
in Unknown on line 0
*
The only thing which is confusing me is that when I did phpize even that I already installed xampp server which means I have PHP running. FFMPEG phpize did not work and I had to install php-devel. Does that mean that FFMPEG is configured with PHP, other than the installed with XAMPP? I am not sure what is happening. Whatever I do I always receive this error message in php_error_log file.
It is amazing :) that I just run below command to see what version of PHP is, I have and below are the results which are shocking one because I am in a feeling that I have PHP 5.5 installed and running from XAMMP.
[root#localhost ~]# php -v
PHP 5.2.6 (cli) (built: May 8 2008 08:53:44)
Copyright (c) 1997-2008 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies
How can I get this covered that if I simple install XAMPP server on linux and want to install and configure FFMPEG along with?
My guess would be that the versions of php and the module you installed do not match. So run make sure both packages are installed from the same source and are both current.
EDIT: According to the XAMPP site, Fedora is not supported, they specify Ubuntu, SuSE, RedHat, Mandrake and Debian. So I would make sure you do not use the php package provided by Fedora. Or (if you have the liberty), choose a different OS.

Categories