如何启用首先安装memcached的igbinary

时间:2011-07-26 12:49:07

标签: php memcached igbinary

我已经使用libmemcached安装了memcached。我还安装了igbinary

这是我的php.ini:

; Directory in which the loadable extensions (modules) reside.
;extension_dir = "./"
extension_dir = "/usr/local/lib/php/extensions/no-debug-non-zts-20060613/"

extension=apc.so
apc.enabled=1
apc.shm_size=128M

extension=memcached.so
session.save_handler=memcached
session.save_path="127.0.0.1:11211"

extension=igbinary.so
session.serialize_handler=igbinary
igbinary.compact_strings=On

当我运行phpinfo()时,我看到启用了igbinary,但是对于memcached,不是

apc
Serialization Support   php, igbinary 

igbinary
igbinary support    enabled
igbinary version    1.1.1
igbinary APC serializer ABI     0

Directive   Local Value Master Value
igbinary.compact_strings    On  On

Phpinfo()关于memcached:

memcached
memcached support   enabled
Version     1.0.2
libmemcached version    0.51
Session support     yes
igbinary support    no 

最后一行:igbinary support就是问题所在。奇怪的是,正如你在标题apc下看到的那样,有人说:Serialization Support php, igbinary

有人知道为什么我不能为 memcached 启用igbinary吗?

谢谢!

3 个答案:

答案 0 :(得分:11)

您无法启用它,因为PECL memcached不是使用'--enable-memcached-igbinary'构建的

PECL安装不会将此作为标志,因此以下是如何使用它构建pecl memcached(以下示例在ubuntu上作为root)

#if you have libmemcached-dev < 1.0.X need to run: sudo apt-get purge libmemcached-dev
apt-get install libevent-dev
pecl install igbinary    

#cant do sudo pecl install memcached-2.1.0 cuz it wont let me use igbinary
#compiling manually per http://www.neanderthal-technology.com/2011/11/ubuntu-10-install-php-memcached-with-igbinary-support/

#install libmemcached v 1.0.X for pecl memcached 2.1.0
cd /tmp
libmemcached_ver="1.0.15"
wget https://launchpad.net/libmemcached/1.0/${libmemcached_ver}/+download/libmemcached-${libmemcached_ver}.tar.gz
tar xzvf libmemcached-${libmemcached_ver}.tar.gz
cd libmemcached-${libmemcached_ver}/
./configure
make
make install
cd ../
rm -r libmemcached-${libmemcached_ver}

#install memcached PECL extension
pecl_memcached_ver="2.1.0"
pecl download memcached-${pecl_memcached_ver}
tar xzvf memcached-${pecl_memcached_ver}.tgz
cd memcached-${pecl_memcached_ver}/
phpize
./configure --enable-memcached-igbinary
make
make install
cd ..
rm -r memcached-${pecl_memcached_ver}

echo "extension=igbinary.so" > /etc/php5/fpm/conf.d/igbinary.ini
echo "extension=memcached.so" > /etc/php5/fpm/conf.d/memcached.ini

#now restart your PHP server

加载一个phpinfo()页面,你现在应该在memcached部分看到'igbinary support:yes'。

答案 1 :(得分:10)

您可以检查 Memcached :: HAVE_IGBINARY 常量,看看您的memcached扩展是否是使用 - enable-memcached-igbinary 编译的。

来源:http://php.net/manual/en/memcached.constants.php

<强>的Memcached :: OPT_SERIALIZER

  

指定用于序列化非标量值的序列化程序。该   有效的序列化程序是Memcached :: SERIALIZER_PHP或   Memcached的:: SERIALIZER_IGBINARY。后者只有在支持时才受支持   memcached配置了--enable-memcached-igbinary选项和   加载了igbinary扩展。

     

类型:整数,默认值:Memcached :: SERIALIZER_PHP。

<强> Memcached的:: HAVE_IGBINARY

  

指示是否可以使用igbinary序列化程序。

     

输入:boolean。

答案 2 :(得分:1)

如果您在Mac上工作并使用MacPorts,则可以使用此命令安装带有igbinary支持的php5-memcached扩展:

sudo port install php5-memcached +igbinary

+igbinary指定php5-memcached端口的变体。

该命令将在Mac上安装启用了igbinary的memcached扩展名。

您可以在此处详细了解端口变体:http://guide.macports.org/#using.variants