How Do You Fix a memcached.so Error when Running PHP Too?

Problem scenario
You get an error about memcache and you are running PHP. Or you get an error "Unable to load dynamic library "memcached.so"? You run "php --version" and you see an error about memcache or memcached (e.g., a missing memcached.so file). What should you do?

Possible Solution #1
Get a memcached.so file from a working Linux server and place it in the directory that the error message showed in the php --version command. If the OS is the exact same as a working server, you could try the location mentioned in the error message. Alternatively you could run this to find it: sudo find / -name memcached.so

Possible Solution #2
You could run this (where "/path/to/pecl" is the result of this command "which pecl"):

sudo /path/to/pecl install memcached

Possible Solution #3
Check the permissions of the memcached.so file if it exists. The file may have incorrect permissions that keep it from being usable.

Possible Solution #4
Is the memcached.so file corrupt or too small? There may be a problem with it. You may need to recreate it. You may want to back it up before you recreate it just to be sure.

Possible Solution #5
If you are using brew, see this posting: https://stackoverflow.com/questions/7860404/how-to-enable-the-memcached-php-extension-after-installing-with-homebrew

For future reference:
To find the version of memcached installed, try these commands:

rpm -qi libmemcached
yum list installed | grep memcache
which memcached
memcached -h

Leave a comment

Your email address will not be published. Required fields are marked *