0

I have an Ubuntu machine with nginx and memcache running, and I'm trying to use PHP with Memcached. I'm getting Fatal error: Class 'Memcached' not found.

The ini file is loaded from /etc/php5/fpm/php.ini, and all other additional .ini files are parsed, except memcached.ini (even after restarting nginx) as seen in phpinfo()'s output.

output for phpinfo()

I tried apt-get install php5-memcache and it completed without errors. However, pecl install memcached fails with the below error:

In file included from /tmp/pear/temp/memcached/php_memcached.h:22:0, from /tmp/pear/temp/memcached/php_memcached.c:47: /tmp/pear/temp/memcached/php_libmemcached_compat.h:5:40: fatal error: libmemcached-1.0/memcached.h: No such file or directory compilation terminated. make: *** [php_memcached.lo] Error 1 ERROR: `make' failed 

The server has libmemcache in /usr/include/libmemcached, but even pecl install with --with-libmemcache=/usr/include/libmemcached fails.

The output for php -i | grep -i memcache is as below:

/etc/php5/cli/conf.d/memcached.ini, memcached memcached support => enabled libmemcached version => 0.44 Registered save handlers => files user memcached PWD => /usr/include/libmemcached _SERVER["PWD"] => /usr/include/libmemcached 

I'm not sure what else to check. Much appreciated if someone could help me out with something to fix this.

Thanks!

[UPDATE] Memcached is working from cli.

2 Answers 2

2

I solved the issue. The only thing I had to do was restart php5-fpm
sudo service php5-fpm restart.

Found this in - https://insready.com/en/blog/building-nginx-microcaching-mariadbmysql-php-fpm-debian-6-apc-memcache-drupal-7-server

0

What is the output of

php -i |grep memcache

I've used memcache for storing php sessions as well as Magento Cache & Sessions.

There are two things not to be confused with:

  1. Memcached -> Note the 'd' which is a daemon listens on port no: 11211. It can be used to store php sessions instead of file system etc..

  2. Memcache -> a module usually not compiled with php. it's used when you want to store your php sessions in memcached.

so if php -i |grep memcache shows you have memcache installed. Then you need to install memcached (daemon) to be able to use/send sessions to it.

1
  • I have installed Memcached, and not Memcache - adding the output for php -i | grep -i memcache to my question. But again, the ini loaded here is from php5/cli/ and for nginx is from php5/fpm/. I am not sure if it really matters, because the conf.d is the same. Commented Jan 7, 2014 at 10:34

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.