PHP Startup: Unable to load dynamic library php_msgpack_serialize - php

PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/20131226/memcached.so' - /usr/lib/php/20131226/memcached.so: undefined symbol: php_msgpack_serialize in Unknown on line 0
Earlier today, I enabled forwarding of messages to root#localhost on my server to beam back to my personal email.
I have been receiving the above error message at 30 minutes intervals since. Of course, I checked and there's a PHP session cleaning script attached to cron to run at 30 minutes interval.
I have been searching around but couldn't find any specific solution.
My setup:
memcached 1.4.25
PHP 7.0
nginx/1.10.0
mysql Ver 14.14 Distrib 5.7.13
Ubuntu Server LTS 16.04
The closest I found to my issue above was this: http://community.rtcamp.com/t/php-warning-error-php-msgpack-serialize/6262 but there's no answer on that thread.

First you need to work out which PHP ini files are being loaded. From command line you can run php --ini. Technically apache/nginx can be running a different version, and you can look up using phpinfo(); exit(); test script if you want to view that one instead. As you're using cron, you're using the command line version anyway.
In one of these files you will find a line similar to:
extension="memcache.so"
If you don't need this extension at all, then just comment it out by prepending it with a ;:
;extension="memcache.so"
If you DO need the extension then it sounds like you need to rebuild this module. The easiest way is using PECL.
pecl install memcache
You might need to follow some instructions whilst running the install. Once it's done, you should be able to run php -v and it shouldn't output the same warning. If this has worked and you just see the php versions, you should restart nginx (if you need it on the website, the command line one should work instantly). :
sudo service nginx restart

I guess you can get a help from a similar topic on the site here.
But briefly, one of your extensions is loading memcache and the path in that is not correct.
You should find it in your php.ini and fix the path manually.

It means there is an extension=... or zend_extension=... line in one of your php configuration files (php.ini, or another close to it) that is trying to load that extension : ixed.5.2.lin
Unfortunately that file or path doesn't exist or the permissions are incorrect.
Try to search in the .ini files that are loaded by PHP (phpinfo() can indicate which ones are) - one of them should try to load that extension.
Either correct the path to the file or comment out the corresponding line.

Check if msgpack extension is installed and enabled (php -i | grep msgpack).
It seems that PHP in Ubuntu is compiled with it by default.
If it's installed and enabled, then check you memcached extension. Maybe you are using it from a previous installation or something similar.

tl;dr: I eventually had to clear everything PHP that is less than php7.0 from my server manually, along with their related cron jobs.
Long story:
Going through my running process (ps -aux | grep 'php'), I realized php5 is still in there running. Everything on my server uses PHP7, so that lingering process was redundant, plus there was a cron job that runs a session cleaning job on the php5 somewhere, using a script which goes looking for the so-called missing Memcached file.
After removing all phps that are less than php7 from system via apt, I also went in to delete all the existing folders that are less than php7 in /usr/lib/php5 and or /usr/lib/php/ along with their cron related jobs found in /etc/cron.d/php5 and or /etc/cron.d/php/
No more whining warnings from PHP session cleaning about memcache

I was getting a similar error with memcache.so and I noticed there was a new version of memcache that was installed the moment the system ran 'pecl install memcache' (automatically that updated to the latest version). The new version caused that error so I had to change the version 1 version lower to pecl install memcache-4.0.5.2 and it worked. Thanks #Farkie for that insight, that's when I realized that there was a new version that just came out a few days ago and that was it!

Just install msgpack extension and the error message should disappear:
apt install php-msgpack
You might also be missing igbinary extension:
apt install php-igbinary

Related

Class 'Memcache' not found in config.php file [duplicate]

I've pasted the example from php.net for using memcached in php and I'm getting:
Fatal error: Class 'Memcache' not found
I have this in my php.ini:
[memcache]
memcache.hash_strategy = "consistent"
memcache.max_failover_attemps = 100
memcache.allow_failover = 1
Here's info from php -i and php -m respectively:
php -i | grep -i memcache
memcached
memcached support => enabled
libmemcached version => 0.37
Registered save handlers => files user sqlite memcached
php -m | grep -i memcache
memcached
So php seems to have loaded memcached as a module, and php info says that it is loaded and is using v .37. I have not tried yet via apache, I've only been using this through cli right now. Any thoughts?
There are two extensions for memcached in PHP, "memcache" and "memcached".
It looks like you're trying to use one ("memcache"), but the other is installed ("memcached").
Dispite what the accepted answer says in the comments, the correct way to install 'Memcache' is:
sudo apt-get install php5-memcache
NOTE Memcache & Memcached are two distinct although related pieces of software, that are often confused.
EDIT
As this is now an old post I thought it worth mentioning that you should replace php5 with your php version number.
I found solution in this post: https://stackoverflow.com/questions/11883378/class-memcache-not-found-php#=
I found the working dll files for PHP 5.4.4
I don't knowhow stable they are but they work for sure. Credits goes to this link.
http://x32.elijst.nl/php_memcache-5.4-nts-vc9-x86.zip
http://x32.elijst.nl/php_memcache-5.4-vc9-x86.zip
It is the 2.2.5.0 version, I noticed after compiling it (for PHP 5.4.4).
Please note that it is not 2.2.6 but works. I also mirrored them in my own FTP. Mirror links:
http://mustafabugra.com/resim/php_memcache-5.4-vc9-x86.zip http://mustafabugra.com/resim/php_memcache-5.4-nts-vc9-x86.zip
For OSX users:
Run the following command to install Memcached:
brew install memcached
The right is php_memcache.dll. In my case i was using lib compiled with vc9 instead of vc6 compiler. In apatche error logs i got something like:
PHP Startup: sqlanywhere: Unable to
initialize module Module compiled with
build ID=API20090626, TS,VC9 PHP
compiled with build ID=API20090626,
TS,VC6 These options need to match
Check if you have same log and try downloading different dll that are compiled with different compiler.
I went into wp-config/ and deleted the object-cache.php and advanced-cache.php and it worked fine for me.

How to install pthreads on a phpfarm php installation

Documenting my struggles to help others and hopefully get some feedback on how I could have done it better.
The command pecl install pthreads fails due to the php installed on my ubuntu 13.04 box not having zts configured.
Options:
1) The ubuntu respository does not have a php package with zts enabled. As of this post, ubuntu only has php 5.4.9 in it's repository (Released: 22 Nov 2012). It is possible to compile a php version from source - which I eventually did (see below), but..
2) I .. ALSO .. wanted to use phpfarm for the ability to run different versions of PHP on my local setup. On github, there is Christian Weiske's original contribution here (phpfarm) and a fork that he has contributed to, by François Poirotte - also called phpfarm. Francois' fork has a few more options to configure ('post-install customization') but I was not able to make that work with a PECL extension. I'm curious to know if misunderstood how to do that, because it looks to me that it just simply does not take PECL commands.
3). Prior to recompiling php from source, I loaded phpfarm (tried both versions), enabled php-fpm (FastCGI) and was able to get my apache2 server to use a phpfarm version (5.5.10) which showed up in a phpinfo() output. But the php-cli always showed the original php version (5.4.9) in the cli (run: php -v). Running (run: php -i | grep php.ini) showed /etc/php5/cli but I had previously removed php5 and aptitude show php5 returned a state of 'not installed.' I even renamed the /etc/php5 directory to see if I could force the system to use the phpfarm php version. Obviously, this is incorrect thinking and I went on to simply compile php 5.6 from source. But, is there something more to do to get a phpfarm php to be used in the cli? I read that the cli loads it's configuration file on a per command basis, unlike the apache2. If I could have run the 5.5.10 version (configured with zts) then I could have then done pecl install pthreads and then re-complied the phpfarm 5.5.10 version with pthreads enabled. Although it appears I will be able to run various versions of php in the apache server, will I ever be able to switch-phpfarm to another version and see it working in the php-cli? Also, I was uncertain on where I could have loaded a pthreads file for the phpfarm compile process to find and use it; could I have done it that way?
4) This stackoverflow post, essentially posted by Joe Watkins - the developer of pThreads is a perfect how-to on getting pThreads installed on a Ubuntu system that has had php configured with zts (Zend Thread Safety). (Thanks Joe!)
A nice tutorial on using phpfarm configured with fast-cgi and the apache server to help run websites under different php configurations.
So what gives with php, php-cli and the phpfarm?
I'm not sure about phpfarm, but do know of another solution ...
Multi
A tool for maintaining multiple installations of PHP in multiple configurations
https://github.com/datingvip/multi
This is a bit more user orientated, will allow you to build many configurations and versions of php, any tagged release of php, and any patched version from any fork of php-src.
In addition, because I wrote it, it will install pthreads for you.
git clone https://github.com/datingvip/multi
cd multi
VERSION=5.5.10 DBG=no-debug ZTS=zts ./php.multi
The above commands will yield an installation of PHP (in one suitable configuration, of one version) in /opt/php.
Look at php.defaults for configuration options and adjust before building
Should configuration fail on, for example, something related to a library like libxml2, it will usually be the case that
sudo apt-get install library-dev
Where library is replaced with the name of the library holding up the build, will fix the problem for you. If it does not, a quick google should get you going again.
Once the build is complete
source /path/to/multi/php.env 5.5.10
Note: multi will always install pthreads for any zts version automatically
I hope that gets you somewhere ...

PHP memcached - php_msgpack_serialize in Unknown on line 0

Recently upgraded PHP and ran into the following error message while updating:
php_msgpack_serialize in Unknown on line 0
So first of all, never heard of this package. All searches for this package leads to a single PECL repo (which really doesn't mean anything either) - which has about zero mentions from the community.
A few more searches and I tracked the origin down to a repo for php-memcached-dev - a repository I've never seen or heard of.
Of course, I have heard of the actual memcached library repo: libmemcached
I tried looking for this module everywhere for a sign of it being a legit part of centos but i can't seem to get any good/reliable results.
Places I searched for any sign of this package and/or repository:
http://pkgs.org/
http://stackoverflow.com
http://php.net
http://centos.org
Just searched https://bugs.php.net too...
I don't want to seem paranoid here, but I'm not even sure if this is legit at this stage.
Shrug - I dunno. I'm keeping my server turned off though until I see something else. Anyone have some advice/input ?
For the paranoid (and yes, I found it from being a little bit myself), here is an ugly google search : php_msgpack backdoor (note: only has 2 3 search results. Check out the date in the 2nd 3rd. i haven't clicked it myself and would not recommend anyone else click it either) This seems to be a rkhunter search looking for the same file being reported above. Probably just a coincidence but who knows. Thought I'd push it out there anyways.
UPDATE: Well, long story short this turned out to be an issue with a version of PHP that was installed with Cent. It has been fixed with the latest version.
On Ubunu 16.04 with PHP 5.5 from the Ondrej-PPA (https://launchpad.net/~ondrej/+archive/ubuntu/php) I could solve the problem by installing the package php-msgpack:
sudo apt-get install php-msgpack
And than enabling the php-msgpack with
sudo phpenmod msgpack
Perhaps you ave to restart apache2 after that if you use it with PHP.
Than this error is gone:
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/20121212/memcached.so' - /usr/lib/php/20121212/memcached.so: undefined symbol: php_msgpack_serialize in Unknown on line 0
One last thing to check:
msgpack extension must be loaded before memcached.
In my scenario extensions were loaded alphabetically and therefore memcached was loaded before msgpack. Php cli didn't work until I loaded msgpack before memcached.
Following commands solved my issue.
sudo apt-get install php-igbinary
sudo apt-get install php-msgpack
sudo service php7.3-fpm reload #Change to your version
Reference:
https://laracasts.com/discuss/channels/forge/php-71-update-broken-memcached
If you land here in Oct 2020 because you're getting an error after upgrading and you're using the repository ppa:ondrej/php you need to install the specific version of msgpack because all-of-a-sudden memcached is looking for this shared object.
We're running php 7.3 from this repo and although php-msgpack was installed, we needed to install php7.3-msgpack (which wasn't needed until this upgrade). No need to "enable" it as mentioned in the accepted answer. Just restart php.
Two steps:
sudo apt install php7.3-msgpack
sudo systemctl restart php7.3-fpm.service
http://msgpack.org/
http://pecl.php.net/package/msgpack
https://code.google.com/p/php-msgpack/
If your codebase doesn't use MsgPack, you can remove it from the php.ini and/or smaller files that mention it in the php.d/* subdirectories.
Well, long story short this turned out to be an issue with a version of PHP that was installed with Cent. It has been fixed with the latest version.

Mongodb running with node and PHP

I am new to Node.js and MongoDB. I have successfully got the mongoDB running with node.js and am able to start it up and store data inside of collections. So the server is already running on localhost:27017 and works when accessing localhost:28017 .
Now that I have it running and working within Node, I wanted to test MongoDB out with PHP on my Xampp server running on Ubuntu, but am not able to get the phpinfo() to say it is using mongo yet.
I have followed the steps here to configure and install the driver. I have moved the mongo.so file to my xampps extensions and added the appropriate line in php.ini + restarted. But phpinfo() still doesn't show it.
I guess i am confused on the aspect of where do i put the mongo-php-driver folder? is this installed into the Xampp server as well, if so where do i put it?
It is already running and working using node.js , so was just getting confused why it wasn't working properly or getting connected.
Also while I'm at it, Is it possible to have php and node.js use the same mongoDB server running on port 27017?
EDIT:
I was able to get the server to at least give me an error message about the file after i edited the extension_dir to the correct path
extension_lib = "/opt/lampp/lib/php/extensions/no-debug-zts-20090626"
i am now getting this error
Warning: PHP Startup: Unable to load dynamic library '/opt/lampp/lib/php/extensions/no-debug-non-zts-20090626/mongo.so' - /opt/lampp/lib/php/extensions/no-debug-non-zts-20090626/mongo.so: wrong ELF class: ELFCLASS64 in Unknown on line 0
i guess I needed to change that php.ini option to get it to load properly. but it seems I have compiled the wrong mongo.so build. I try again.
Thanks
According to this:
http://montenasoft.com/en/blog/how-install-pecl-php-extension-64bit-linux-while-you-are-using-32bit-xampp
Because xampp is compiled with 32 bit, but the mongo driver you compile is 64 bit.
You may have to compile your mongo driver with these:
phpize
CFLAGS=-m32 CPPFLAGS=-m32 CCASFLAGS=-m32 ./configure
make
sudo make install
Or just install apache2, mysql, php separately. I think this is a better option.

CentOS - Mongo class not found in PHP

I need the MongoDB PHP driver on my CentOS 5.4 machine. My PHP version is 5.1.6. I downloaded the RPM and installed it. That created several files in /usr/bin directory. I copied
/usr/bin/mongo
to
/usr/lib/php/modules
which was what extension_dir showed on doing phpinfo();.
I also added
extension=mongo.so
in /etc/php.ini.
However on executing my PHP script, i still get
Mongo class not found.
What's going wrong here ?
Also, my phpinfo() shows PHP version 5.1.6 whereas running PHP from command line shows 5.3.3. Could anything be wrong with that ?
Thanks in advance.
You're saying your webserver and command line PHP report different versions. These are going to be installed in different locations, and their extensions are API incompatible with each other.
When you installed the php_mongo extension, it may have used the command line php to determine the directory to install the extension to.
Make sure you have the correct php_mongo for the php version of your webserver, and it is in the correct extensions directory. (get the directory from the php.ini returned by phpinfo())
I hope you realise PHP 5.1 is also many years out of date. Unless you have a specific reason to use a version that old, you should also look at upgrading to a more recent version.
Edit:
Just read your comment "I must also mention that /usr/bin/mongo is a binary executable file but its not having a .so extension. Im copying it as is to /usr/lib/php/modules"
No no no! :)
This is the mongo command line client. This is not the PHP extension!
You can run a find /* -name "mongo.so" to see where the installer put the file, this will probably also give you an indication of which version of PHP it was installed for.
It looks as though you are confusing the RPM-packages for the MongoDB server with the requirements to install the MongoDB PHP driver. The PHP driver provides access to the server from your PHP applications, and does not install any command line tools.
restart httpd !
yum service httpd restart

Categories