Fresh Blurbs

Install PECL Memcache with XAMPP and PHP4

XAMPP is an absolutely wonderful, packaged, self-contained distribution of apache, mysql, php and tons of hard-to-install php extensions. Not only does it make sysadmin's life easier, by solving 99.9% of LAMP problems out-of-the-box, but it also allows PHP-vendors to create packaged distributions of complex systems.

However, even with a long list of packaged extensions, obviously there may be a need to install an additional one. PECL Memcache client of memcached distributed cache server, is a very probable candidate for high-load systems.

Unfortunately, PECL is broken in a vanilla XAMPP installation with php4. Typically you won't be able to use "pecl" directly and when you try to install manually with phpize you will get an error like:\ " PHP Warning: Unknown(): Unable to load dynamic library '/opt/lampp/lib/php/extensions/no-debug-non-zts-20020429/' - /opt/lampp/lib/php/extensions/no-debug-non-zts-20020429/ undefined symbol: OnUpdateLong in Unknown on line 0"

Below is step-by-step guide of how to install a PECL extension (Memcache in this case) in the latest XAMPP:

make sure you uninstall all and any PHP installations you may have had before along with PECL and PEAR
 Download and install XAMPP 1.6.1
 Add /opt/lampp/bin to your PATH
 Download and install XAMPP Development Package 
caution: it will overwrite any configuration changes you may have made previously
backup /opt/lampp/include directory to /opt/lampp/include-bak. This directory
is part of XAMPP-DEV but seems to be broken vis-a-vis PECL
Download source distribution of the PHP corresponding to your XAMPP installation
(for 1.6.1 it is PHP 4.6.4) and put it under "include" older so that the root of the
php source distribution is /opt/lampp/include/php (rename the php-4.6.4 directory
to php after unpacking).
Run "./configure" and "make" on that php source. 
Caution: Do NOT run "make install"!!!
Download memcache-2.1.2 anywhere
# cd memcache-2.1.2
# phpize
# ./configure
# make
# make install
Edit /opt/lampp/etc/php.ini and add a line:


memcache is just a client-side of the whole cache thing. You need to install server, as well, to do anything useful. The server (called memcached, as in memcache-daemon) requires libevent dynamic library. There is a small pitfall in instaling libevent. The installation itself is a straightforward "configure, make, make install" but once you install libevent and memcached, you may not be able to run memcached and get the following error, instead:

"memcached: error while loading shared libraries: open shared object file: No such file or directory"

This is because memcached was not able to find the library location. Run memcached with:

$ LD_DEBUG=libs memcached -v

to see where is it looking for the libraries and install libevent there.

I had to run libevent configure as:

./configure --prefix=/usr

to fix this problem. You will need to uninstall/recompile/reinstall memcached if you reinstall libevent.


comments powered by Disqus