How to enable igbinary with memcached installed first
Asked Answered
D

4

14

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!

Doublereed answered 26/7, 2011 at 12:49 Comment(1)
how did your selected answer helped you ? I am in the same situation, but couldn't understand the answer what it means. Can you explain what did you do ?Tresa
L
13

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.

Luminary answered 26/7, 2011 at 14:3 Comment(1)
I guess the question was, if memcached was not compiled with enabled-memcached-igbinary, how to change the settings ? or do we have to reinstall memcached again ?Tresa
P
13

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.

Pradeep answered 26/12, 2012 at 17:18 Comment(3)
Thank you, @Pradeep !!!!!!! The other site wasn't quite working, but your instructions did the trick for me. Huge help.Rhoads
np. too bad this isn't documented better as its pretty powerful.Pradeep
Worked like a charm in ubuntu 12.04 - thanks! Exact image tried is from puphpet (box.puphpet.com/ubuntu-precise12042-x64-vbox43.box)Spartan
I
3

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

Immixture answered 14/7, 2022 at 13:26 Comment(0)
K
2

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

Knifeedged answered 14/12, 2011 at 14:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.