在 CentOS 6 上安装 Memcached 问题

在 CentOS 6 上安装 Memcached 问题

在我的 CentOS 6 服务器 (PHP 5.4.13) 上安装 Memecached 时遇到了麻烦。通常所有 DigitalOcean 帮助指南都可以顺利运行(它是 MediaTemple 服务器,支持人员不会安装 memcached),但我在安装 PHP 扩展的最后一步遇到了困难:https://www.digitalocean.com/community/tutorials/how-to-store-php-sessions-in-memcached-on-a-centos-vps.最后一步让我跑起来

pecl install -f memcached-1.0.0

一切似乎都配置得很顺利,直到我必须真正进行构建:

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

有什么想法吗?我已经花了几个小时来排除故障,实际上已经尝试了 2-3 种其他不同的方式安装 Memecached(如果不行就清除服务器)。

答案1

问题是,DigitalOcean 的指南是错误的。有两个 PECL 扩展 - memcache 和 memcached,它们是不同的扩展。要将会话存储在 memcached 守护进程中,您需要 memcache PECL 扩展,而不是 memcached 扩展。

因此,使用 yum (php-pecl-memcache) 或 pecl (pecl install memcache) 安装一个。强制使用某个版本可能也不是个好主意,除非您确切知道为什么需要这个特定版本。

另外,与 PHP 捆绑在一起的 php.ini(或任何示例)实际上已经包含一个关于如何使用 memcached 守护程序在其中存储会话的示例。您只需更改此行中的主机名并取消注释即可。

相关内容