Ubuntu – how to install pecl memcached

memcachedpeclPHPUbuntu

i need to install memcahced (not memcache) on my computer (ubuntu 10.10 and php 5.3.3), i did the follwoing:
$ apt-get install php5-memcached libmemcached-tools libmemcached5
=>DONE SUCESSFULLY
$ pecl install memcached
it ends with the following error

checking for libmemcached location... configure: error: memcached support 
requires libmemcached. Use --with-libmemcached-dir= to specify the prefix 
where  libmemcached headers and library are located

any idea is highly appreciated

Best Answer

No need to use pecl. Install memcached extension module for PHP5:

 $ sudo apt-get install php5-memcached

test.php:

<?php
        $m = new Memcached();
        $m->addServer('127.0.0.1', 11211);
        var_dump($m->getStats());
?>

$ php test.php 
array(1) {
  ["127.0.0.1:11211"]=>
  array(24) {
    ["pid"]=>
    int(2462)
    ["uptime"]=>
    int(129)

To test memcached use telnet:

$ telnet 127.0.0.1 11211
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
stats
STAT pid 2462
STAT uptime 1039
STAT time 1298284545
STAT version 1.4.5
STAT pointer_size 32
STAT rusage_user 0.092005
STAT rusage_system 0.000000