Installing Memcached on CentOS 6 Issue

Having a devil of a time getting Memecached on my CentOS 6 server (PHP 5.4.13). Usually all of the DigitalOcean help guides work smoothly (it’s a MediaTemple server and support won’t install memcached), but I’m hung up on the last step installing the PHP extension: https://www.digitalocean.com/community/tutorials/how-to-store-php-sessions-in-memcached-on-a-centos-vps. The last step has me running

pecl install -f memcached-1.0.0

Everything seems to configure smoothly until I have to actually make the build:

running: make
/bin/sh /root/tmp/pear-build-rootOmsGie/memcached-1.0.0/libtool --mode=compile cc -I/usr/include/php  -I. -I/root/tmp/memcached -DPHP_ATOM_INC -I/root/tmp/pear-build-rootOmsGie/memcached-1.0.0/include -I/root/tmp/pear-build-rootOmsGie/memcached-1.0.0/main -I/root/tmp/memcached -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -I/usr/local/include  -DHAVE_CONFIG_H  -g -O2   -c /root/tmp/memcached/php_memcached.c -o php_memcached.lo
libtool: compile:  cc -I/usr/include/php -I. -I/root/tmp/memcached -DPHP_ATOM_INC -I/root/tmp/pear-build-rootOmsGie/memcached-1.0.0/include -I/root/tmp/pear-build-rootOmsGie/memcached-1.0.0/main -I/root/tmp/memcached -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -I/usr/local/include -DHAVE_CONFIG_H -g -O2 -c /root/tmp/memcached/php_memcached.c  -fPIC -DPIC -o .libs/php_memcached.o
/root/tmp/memcached/php_memcached.c: In function ‘php_memc_get_impl’:
/root/tmp/memcached/php_memcached.c:369: warning: passing argument 4 of ‘memcached_mget_by_key’ from incompatible pointer type
/usr/local/include/libmemcached-1.0/get.h:68: note: expected ‘const char * const*’ but argument is of type ‘char **’
/root/tmp/memcached/php_memcached.c:406: warning: assignment discards qualifiers from pointer target type
/root/tmp/memcached/php_memcached.c:438: warning: passing argument 4 of ‘memcached_mget_by_key’ from incompatible pointer type
/usr/local/include/libmemcached-1.0/get.h:68: note: expected ‘const char * const*’ but argument is of type ‘char **’
/root/tmp/memcached/php_memcached.c: In function ‘php_memc_getMulti_impl’:
/root/tmp/memcached/php_memcached.c:575: warning: passing argument 4 of ‘memcached_mget_by_key’ from incompatible pointer type
/usr/local/include/libmemcached-1.0/get.h:68: note: expected ‘const char * const*’ but argument is of type ‘char **’
/root/tmp/memcached/php_memcached.c:605: warning: assignment discards qualifiers from pointer target type
/root/tmp/memcached/php_memcached.c:608: warning: assignment discards qualifiers from pointer target type
/root/tmp/memcached/php_memcached.c: In function ‘php_memc_getDelayed_impl’:
/root/tmp/memcached/php_memcached.c:724: warning: passing argument 4 of ‘memcached_mget_by_key’ from incompatible pointer type
/usr/local/include/libmemcached-1.0/get.h:68: note: expected ‘const char * const*’ but argument is of type ‘char **’
/root/tmp/memcached/php_memcached.c: In function ‘zim_Memcached_fetch’:
/root/tmp/memcached/php_memcached.c:799: warning: assignment discards qualifiers from pointer target type
/root/tmp/memcached/php_memcached.c:802: warning: assignment discards qualifiers from pointer target type
/root/tmp/memcached/php_memcached.c: In function ‘zim_Memcached_fetchAll’:
/root/tmp/memcached/php_memcached.c:850: warning: assignment discards qualifiers from pointer target type
/root/tmp/memcached/php_memcached.c:853: warning: assignment discards qualifiers from pointer target type
/root/tmp/memcached/php_memcached.c: In function ‘zim_Memcached_getServerList’:
/root/tmp/memcached/php_memcached.c:1487: warning: assignment makes pointer from integer without a cast
/root/tmp/memcached/php_memcached.c: In function ‘zim_Memcached_getServerByKey’:
/root/tmp/memcached/php_memcached.c:1526: warning: assignment from incompatible pointer type
/root/tmp/memcached/php_memcached.c: In function ‘zim_Memcached_getStats’:
/root/tmp/memcached/php_memcached.c:1565: warning: assignment makes pointer from integer without a cast
/root/tmp/memcached/php_memcached.c: In function ‘zim_Memcached_getVersion’:
/root/tmp/memcached/php_memcached.c:1629: warning: assignment makes pointer from integer without a cast
/root/tmp/memcached/php_memcached.c: In function ‘zim_Memcached_setOption’:
/root/tmp/memcached/php_memcached.c:1783: error: ‘memcached_st’ has no member named ‘hash’
/root/tmp/memcached/php_memcached.c: In function ‘php_memc_new’:
/root/tmp/memcached/php_memcached.c:1901: error: ‘zend_class_entry’ has no member named ‘default_properties’
/root/tmp/memcached/php_memcached.c: In function ‘php_memc_do_result_callback’:
/root/tmp/memcached/php_memcached.c:2322: warning: assignment discards qualifiers from pointer target type
/root/tmp/memcached/php_memcached.c:2325: warning: assignment discards qualifiers from pointer target type
make: *** [php_memcached.lo] Error 1
ERROR: `make' failed

Any ideas? I’ve been troubleshooting this for hours, and actually have tried installing Memecached 2-3 other different ways (wiping the server if it doesn’t work).

Answer

The problem is, that DigitalOcean howto is just wrong. There are two PECL extensions – memcache and memcached, and those are different extensions. To store sessions in a memcached daemon process you need the memcache PECL extension, not the memcached one.

So install one using either yum (php-pecl-memcache) or using pecl (pecl install memcache). Forcing a version is probably a bad idea too, unless you know exactly why you need this particular version.

Plus, bundled with PHP php.ini (or any it’s samlple) actually does already contain an example about how to use the memcached daemon to store sessions in it. You can simple change the hostname in this line and uncomment it.

Attribution
Source : Link , Question Author : Paul B , Answer Author : drookie

Leave a Comment