0

I'm new to 'Memcache' but I've installed it and I think its' running, so far have I done the following correct?

mkdir memcache
wget http://pecl.php.net/get/memcache-3.0.6.tgz
tar -xvfz memcache-3.0.6.tgz
cd memcache-3.0.6
phpize
./configure
make
make install
echo "extension=memcache.so" >> /usr/local/lib/php.ini
service httpd restart

However when I try and connect using:

$memcache = new Memcache;
$memcache->connect('localhost', 11211) or die ("Could not connect");

I'm provided with: Memcache::connect() [memcache.connect]: Can't connect to localhost:11211, Connection refused (111)

I've seen people say try and telnet using telnet localhost 11211 but if I try that I get Connection Refused

I've tried replacing localhost with 127.0.0.1 but no luck either.

Have I installed the wrong memcache? If so how can I remove the one I have just added? or is that I needed libevent?

2
  • Dumb question, but is the memcached daemon running? Try running a netstat -lntp and looking for 11211. You can also run ps -axw | grep [m]emcached, if you get nothing you need to start the memcached daemon.
    – d34dh0r53
    Jan 17, 2012 at 0:07
  • @d34dh0r53 no it's not there, but when I type memcached I just get command not found
    – Dan
    Jan 17, 2012 at 0:18

1 Answer 1

3

I'm putting this in an answer now as I think I know your problem. You have only installed the PECL module for memcached which is essentially a client library and not the actual memcache server. You need to download and install the latest memcached daemon from here:

http://memcached.org

Once you have that installed you'll be able to start the daemon and connect to port 11211. As an aside, depending on the distribution you're running there may be a memcached package available to you in your repositories. I would highly recommend you install this package instead of rolling your own memcached as it will greatly simplify upgrading and managing memcached.

2
  • thanks, do I need to remove what I installed previously?
    – Dan
    Jan 17, 2012 at 0:36
  • No, once you have the daemon installed you will use the PECL module to connect to it via PHP.
    – d34dh0r53
    Jan 17, 2012 at 17:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .