开发者

How to enable igbinary with memcached installed first

I have memcached installed with libmemcached. Also I have installed igbinary.

This is my 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

.

When I run phpinfo() i see that igbinary is enabled, but not for 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() about memcached:

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

That last line: igbinary support thats the question. Oddly enough, as you can see under the heading apc there is stated: Serialization Support php, igbinary.

So do someone know why I cannot enable igbinary for memcached?

Thanks!


You can check the Memcached::HAVE_IGBINARY constant to see if your memcached extension was compiled using --enable-memcached-igbinary.

Source: http://php.net/manual/en/memcached.constants.php

Memcached::OPT_SERIALIZER

Specifies the serializer to use for serializing non-scalar values. The valid serializers are Memcached::SERIALIZER_PHP or Memcached::SERIALIZER_IGBINARY. The latter is supported only when memcached is configured with --enable-memcached-igbinary option and the igbinary extension is loaded.

Type: integer, default: Memcached::SERIALIZER_PHP.

Memcached::HAVE_IGBINARY

Indicates whether igbinary serializer support is available.

Type: boolean.


You can't enable it because PECL memcached was not built with '--enable-memcached-igbinary'

PECL install does not take this as a flag, so here is how you can build pecl memcached with it (following example is on ubuntu as 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

Load up a phpinfo() page and you should now see 'igbinary support: yes' under memcached section.


If you work on a Mac and use MacPorts, you can install the php5-memcached extension with igbinary support with this command:

sudo port install php5-memcached +igbinary

The +igbinary specifies a variant of the php5-memcached port.

That command will install an igbinary-enabled memcached extension on your Mac.

You can read more about port variants here: http://guide.macports.org/#using.variants


It's now possible to pass configuration options to pecl install (see the PECL manual)

Here's how you'd install memcached with the igbinary serializer, and all other options left at their default values:

pecl install --configureoptions 'with-libmemcached-dir="no" with-zlib-dir="no" with-system-fastlz="no" enable-memcached-igbinary="yes" enable-memcached-msgpack="no" enable-memcached-json="no" enable-memcached-protocol="no" enable-memcached-sasl="yes" enable-memcached-session="yes"' memcached

The full list of options is defined here (look for the <configureoption> tags): https://github.com/php-memcached-dev/php-memcached/blob/master/package.xml

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜