1

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

Alaa Alomari
  • 638
  • 6
  • 19
  • 37

2 Answers2

3

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
ooshro
  • 11,134
  • 1
  • 32
  • 31
  • i did already... it keeps giving me RES_WRITE_FAILURE response code on set or add and gives "SOME ERRORS WERE REPORTED" on getstats – Alaa Alomari Feb 21 '11 at 10:24
  • @Alaa test connection to memcached – ooshro Feb 21 '11 at 10:36
  • using telnet: stats STAT pid 9012 STAT uptime 14 STAT time 1298285340 STAT version 1.2.6 STAT pointer_size 32 STAT rusage_user 0.000000 STAT rusage_system 0.000000 STAT curr_items 0 STAT total_items 0 STAT bytes 0 STAT curr_connections 2 STAT total_connections 3 STAT connection_structures 3 STAT cmd_get 0 STAT cmd_set 0 STAT get_hits 0 STAT get_misses 0 STAT evictions 0 STAT bytes_read 7 STAT bytes_written 0 STAT limit_maxbytes 1073741824 STAT threads 1 but why do i get errors when use PHP!! :(( – Alaa Alomari Feb 21 '11 at 10:51
  • Add output `php -i` memcached section – ooshro Feb 21 '11 at 11:09
  • Version 1.0.2, libmemcached version 0.40, Session support yes, igbinary support no – Alaa Alomari Feb 21 '11 at 11:37
  • add output: php -r '$m = new Memcached(); $m->addServer("127.0.0.1", 11211); var_dump($m->getStats());' – ooshro Feb 21 '11 at 12:46
  • PHP Warning: Module 'memcache' already loaded in Unknown on line 0 array(1) { ["127.0.0.1:11211"]=> array(24) { ["pid"]=> int(9012) ["uptime"]=> int(8118) ["threads"]=> int(1) ["time"]=> int(1298293444) ["pointer_size"]=> int(32) ["rusage_user_seconds"]=> int(0) ["rusage_user_microseconds"]=> int(172010) **To be Continued in the next comment** – Alaa Alomari Feb 21 '11 at 13:07
  • ["rusage_system_seconds"]=>int(0) ["rusage_system_microseconds"]=> int(244015) ["curr_items"]=> int(0) ["total_items"]=> int(0) ["limit_maxbytes"]=> int(1073741824) ["curr_connections"]=> int(2) ["total_connections"]=> int(4) ["connection_structures"]=> int(3) ["bytes"]=> int(0) ["cmd_get"]=> int(0) ["cmd_set"]=> int(0) ["get_hits"]=> int(0) ["get_misses"]=> int(0) ["evictions"]=> int(0) ["bytes_read"]=> int(37) ["bytes_written"]=> int(472) ["version"]=> string(5) "1.2.6" } } – Alaa Alomari Feb 21 '11 at 13:08
  • it seems the problem was with my apache!! even i restarted it before.. but now,, i restarted it, and it works fine... Thanks alot ooshro. i really appreciate your time and help – Alaa Alomari Feb 21 '11 at 13:32
1

I fixed this by installing libmemcached-devel (I'm on Centos 5.5)

dlsniper
  • 111
  • 3