ryu's blog just a few lines of code

21Sep/110

HOWTO: Install PHP Memcache on Ubuntu

Update, install new software an restart Apache:

# apt-get update && apt-get upgrade

# apt-get install memcached php5-memcache

# /etc/init.d/apache2 restart

Now test it. Start a new memcache instance:

# memcached -u root -d -m 24 -l 127.0.0.1 -p 11211

This instance starts as root user using 24 MB as maximum cache size, listening on port 11211.
On my system, I have this process running now:

13919 ? Sl 0:00 /usr/bin/memcached -m 64 -p 11211 -u memcache -l 127.0.0.1

We can test our running memcache process by connecting via Telnet:

# telnet 127.0.0.1 11211

An overview of the availiable commands, you can find here: http://lzone.de/articles/memcached.htm
If you like to change your default memcached configuration, do the following:

# vim /etc/memcached.conf

Don't forget to restart memcached afterwards:

# /etc/init.d/memcached restart

At this point you would have to start all memcached instances manually. That's a thing I wouldn't like to worry about. So move the commands to rc.local:

# vim /etc/rc.local

Add lines like this before 'exit 0':

memcached -u your-user-name -d -m 16 -l 127.0.0.1 -p 11211

Make sure every instance listens on a different port. For example: 11211, 11212, 11213... etc.

Comments (0) Trackbacks (0)

No comments yet.


Leave a comment

(required)

No trackbacks yet.