2

Below is my phpinfo() output for memcached

memcached

memcached support   enabled
Version 2.1.0
libmemcached version    1.0.4
Session support yes
igbinary support    no
json support    no

I'm using an AWS Linux AMI which is redhat based I believe and uses YUM.

How can I get igbinary support enabled?

Does this have to happen at memcached installation time? I have memcached already working so is there a way I can add this support in now?

thank you

Gilles Quénot
  • 173,512
  • 41
  • 224
  • 223
Adam
  • 19,932
  • 36
  • 124
  • 207
  • 1
    This is more a question for: http://serverfault.com/ Users here are more into programming, so you have a better change to get an answer there. – Green Black Feb 15 '13 at 23:21

2 Answers2

4

I used to compile the memcached stack manually, which included igbinary. This was before I started using the remi repo, which provides updated packages without all the overhead of manual compilation.

Here are the notes I used when I used to compile igbinary manually:

Had to scp the source from another computer due to lack of direct links, the next steps assume pecl/memcached files are local and extracted
$ -> wget http://pecl.php.net/get/igbinary-1.1.1.tgz
$ -> tar -xzvf igbinary-1.1.1.tgz
$ -> cd igbinary-1.1.1
$ -> phpize
$ -> ./configure # No need for extra config params
$ -> make
$ -> make install # This should copy the resulting .so file to the php dir where all modules are stored
$ -> /etc/init.d/httpd restart # I remember having to do this for phpinfo to reflect the setting correctly after the udpate

Now, if you view your phpinfo (or php -i from cli) igbinary support should be set to yes.

-- Update --

Be sure you have the following line in php.ini or igbinary.ini where php can read it:

; Enable igbinary extension module
extension=igbinary.so

-- Update #2 --

Forgot to mention, you need to compile memcached with the following flag in order for it to use igbinary:

--enable-memcached-igbinary

-- Update #3 --

In case anyone stumbles across this in the future. Manually maintaining the PHP stack along with commonly used extensions is a pain, and usually not worth the extra effort. You are better off using your distro's package manager to handle all the heavy lifting, an example of installing php with memcached with igbinary support would look like:

yum install php php-cli php-pecl-memcached php-pecl-igbinary

If your distro's upstream version of php is older and you wish to use a newer version, take a look at the REMI repo: http://blog.famillecollet.com/pages/Config-en

Mike Purcell
  • 19,847
  • 10
  • 52
  • 89
  • thx. I did your steps above and all installed fine. I also added the following to php.ini and I can see more information in phpinfo() about igbinary but the setting in the question is still no... hummmm – Adam Feb 16 '13 at 00:10
  • ;Load igbinary extension extension=igbinary.so ;Use igbinary as session serializer session.serialize_handler=igbinary ;Enable or disable compacting of duplicate strings ; # The default is On. igbinary.compact_strings=On ;Use igbinary as serializer in APC cache (3.1.7 or later) apc.serializer=igbinary – Adam Feb 16 '13 at 00:11
  • If memcached is already installed - should I remove it and reinstall it to use the flag? can I do this with YUM? – Adam Feb 16 '13 at 01:12
  • 1
    I asked the very same question: http://serverfault.com/questions/395922/centos-php-yum-install-with-custom-configure-params . The short answer is no, you cant pass custom compile flags via Yum. So you would have to yum remove memcached, download, and compile it manually, which is a pain. If you are ok with your distro's upstream version of php, you can do this: `yum install php php-cli php-pecl-memcached php-pecl-igbinary`, and let yum handle all the install paths and dependencies. If you need a newer version of PHP, take a look at the REMI repo: http://blog.famillecollet.com/pages/Config-en – Mike Purcell Feb 16 '13 at 01:23
0

Another option, if you don't want to set it up manually, is to use PECL.

Here's an example in Amazon Linux 2:

yum -y install php-pecl-igbinary libmemcached-devel

# Install igbinary first
yes "" | pecl install igbinary
sed -i -e '/extension="igbinary.so"/d' /etc/php.ini
echo 'extension="igbinary.so"' > /etc/php.d/41-memcached.ini

# Then install memcached, being sure to set the enable-memcached-igbinary option to yes
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
sed -i -e '/extension="memcached.so"/d' /etc/php.ini
echo 'extension="memcached.so"' >> /etc/php.d/41-memcached.ini
Ben Y
  • 1,711
  • 1
  • 25
  • 37