Installing and setting up the Memcached server

Memcached is available as a ready-made package in the Remi  repository.

So lets install the Remi repository first:

cd /etc/yum.repos.d
wget http://rpms.famillecollet.com/enterprise/remi.repo

Memcached server install

yum --enablerepo=remi install memcached

 

Edit and use the RPM start script

#adapt options here, like memory available

vim /etc/init.d/memcached

# start service

service memcached start

# add to system boot config

chkconfig memcached on

 

Making it more secure

It’s a good idea to add an IpTables rule to block all outside requests to this server. Add a line like this to your 

-A INPUT -p tcp --dport 11211 -j ACCEPT

 

Testing your Memcached server

# Is the service running?

netstat -tap | grep memcached

You should see an output that look something like this:

tcp 0 0 *:11211 *:* LISTEN 29441/memcached
tcp 0 0 *:11211 *:* LISTEN 29441/memcached

# see some stats with memcached-tool (installed along with RPM):

memcached-tool 127.0.0.1:11211 stats

#127.0.0.1:11211 Field Value
accepting_conns 1
auth_cmds 0
auth_errors 0
bytes 1867
bytes_read 81117
bytes_written 54550
[… etc]

###

Please see the note on the bottom if you plan on using this on Joomla!

###

Installing PECL/Memcached

yum --enablerepo=remi install zlib zlib-devel
yum --enablerepo=remi install libmemcached libmemcached-devel
pecl install memcached

 

Add this line to your php.ini

 extension=memcached.so

 

If you create an test.php file (calling phpinfo() )(after restarting Apache), it should look like this:

Create the file test.php file

vim test.php

or use a test editor and FTP it up.

Insert this into the file.

<?php phpinfo(); ?> 

Open the file in your browser:

http://example.com/test.php

It should look like this:

###

After I set this up on our server and tried to use it on Joomla ( Joomla 2.5 at the time of writing ), Joomla did not have the capability to use the memcacheD php client, but only the memcache php client.

To install the memcache client and not the memcacheD client execute:

pecl install memcache

and place this line into your php.ini

extension=memcache.so

rather than the memcacheD commands.

###

How to: CentOS 5 Virtualmin Joomla 2.5 Memcached PHP client library
Tagged on: