Memcache – How to Install Different Versions with Different LAMPP Versions

lampmemcachexampp

I need to use different versions of lampp (xampp for linux).
I recently also need to use memcache with any version of lampp I might need to use.
Everything is going right if I use the last lampp version 1.7.7 which contains PHP 5.3.8
I simply do

sudo apt-get install php5-memcache
sudo cp -av '/usr/lib/php5/20090626+lfs/memcache.so' '/opt/lampp/lib/php/extensions/no-debug-non-zts-20090626/memcache.so'

The problem is when I try to do the same with an older version of lampp.
For example, I uninstalled lampp 1.7.7 and php5-memcache, then I installed lampp 1.7.1, which contains PHP 5.2.9, but doing

sudo apt-get install php5-memcache

I get a newer version of memcache (20090626) for an older version of php (20060613).
In fact if I try to copy

sudo cp -av '/usr/lib/php5/20090626+lfs/memcache.so' '/opt/lampp/lib/php/extensions/o-debug-non-zts-20060613/memcache.so'

I get this error while starting lampp:

Starting XAMPP for Linux 1.7.1...
PHP Warning:  PHP Startup: memcache: Unable to initialize module
Module compiled with module API=20090626, debug=0, thread-safety=0
PHP    compiled with module API=20060613, debug=0, thread-safety=0
These options need to match
in Unknown on line 0

If I uninstall php5-memcahe and remove memcache.so from lampp extension

sudo apt-get remove php5-memcache
sudo rm /opt/lampp/lib/php/extensions/no-debug-non-zts-20060613/memcache.so

if I try to do

sudo pecl i memcache

I get

pecl/memcache is already installed and is the same as the released version 2.2.6
install failed

So how can I install memcache.so version 20060613 when I'm using lampp 1.7.1?

Best Answer

The simples solution. You need memcache.so build with API 20060613. This is pretty old, but if you go to http://packages.ubuntu.com/hardy/php5-memcache you will find both amd64 and i386 packages. Run

uname -m

to see what architecture you have and download the package accordingly. After you downloaded the package just go in mc open the package, get the memcache.so and copy it on /opt/lampp/lib/php/extensions/no-debug-non-zts-20060613/, and add in php.ini

extension=memcache.so

if is saying it doesn't find memcache.so probably you should adjust extensiondir accordingly.

Restart apache and look at php_info(); It should be there.

On future try to stick on ubuntu/debian versions of php/apache/mysql and don't use lampp. I know is much more easy with lampp, but after you understand what it happen "under the hood" will be more easy for you to build your applications and to understand linux. Another problem with lampp are the security updates. If you are using Ubuntu or Debian versions you will have all the upgrades with the OS and the entire process of upgrading it will take seconds not hours or days.