Search code examples
phpubuntumemcachedphp-7

PHP Startup: Unable to load dynamic library php_msgpack_serialize


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.


Solution

  • 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