by Pep
Ubuntu 10: install PHP memcached with igbinary support
Because I needed the igbinary support for memcached, I couldn’t get the “pecl install” working for the PECL memcached module because it wouldn’t accept my compile flag (–enable-memcached-igbinary). My workaround is posted below.
- Install memcached server
- Install PHP igbinary extension
- Install libmemcached library
- Install PHP memcached extension
# first install memcached server using apt-get
$ apt-get install memcached
# make any changes to the config file, if necessary
$ vi /etc/memcached.conf
$ service memcached restart
Before installing the memcached extension for PHP, we need to install the igbinary package. Igbinary provides binary serialization for PHP objects and data which significantly speeds up the process.
$ pecl install igbinary
Now we need to make sure PHP loads the extension. To do that, open the file “/etc/php5/conf.d/igbinary.ini” and add the following:
[/etc/php5/conf.d/igbinary.ini]
extension=igbinary.so
Next step is to download a dependency called “libmemcached”, which is a C/C++ client library for the memcached server. It can be downloaded from http://libmemcached.org. At the moment of writing, the latest version is 1.0.2, which will be used in the following example.
$ wget http://launchpad.net/libmemcached/1.0/1.0.2/+download/libmemcached-1.0.2.tar.gz
$ tar xzvf libmemcached-1.0.2.tar.gz
$ cd libmemcached-1.0.2/
$ ./configure
$ make
$ make install
It’s time to install the actual memcached PECL extension. This will provide the Memcache class for your PHP code.
$ pecl download memcached
$ tar xzvf memcached-1.0.2.tgz
$ cd memcached-1.0.2/
$ phpize
$ ./configure –enable-memcached-igbinary
$ make
$ make install
What we did to load the igbinary extension, we’ll do it again for the memcached extension. Open the file “/etc/php5/conf.d/memcached.ini” and add:
[/etc/php5/conf.d/memcached.ini]
extension=memcached.so
Save and quit. Last thing to do is to restart the apache webserver, and check if the modules are loaded.
$ service apache2 restart
Memcached should now be loaded and should show up in phpinfo();. Please note that this way of enabling extensions might not work for everyone, depending on how your apache server is set up.
| Print article | This entry was posted by Pep on November 4, 2011 at 10:09 am, and is filed under Computing, Programming. Follow any responses to this post through RSS 2.0. You can leave a response or trackback from your own site. |