Server Setup


by , , revisited on

We have by far the largest RPM repository with NGINX module packages and VMODs for Varnish. If you want to install NGINX, Varnish, and lots of useful performance/security software with smooth yum upgrades for production use, this is the repository for you.
Active subscription is required.

Memcached is a Linux daemon which allows programs to set and get data into RAM for fast access. It comes into great benefit when storing cache data.

Installing Memcached

Here is the command to install it along with corresponding PHP extension:

yum install memcached php-pecl-memcached

Start Memcached Service

Since we installed the service via yum, it’s easy to enable it at boot time and immediately start (CentOS 6):

chkconfig memcached on 
# service memcached start

By default it listens on port 11211, and there’s no big reason in changing it.

Enable Memcached sessions for PHP-FPM

Edit pool definition file to add support for storing session data in RAM. This greatly reduces database load, in case you’ve been using database for session storage.

# vi /etc/php-fpm.d/www.conf
; php_value[session.save_handler] = files 
; php_value[session.save_path] = /var/lib/php/session
php_value[session.save_handler] = memcached 
php_value[session.save_path] = "localhost:11211" 

# service php-fpm reload


There is a script at Github repository, which you can place at the root of any of your websites and access it via /memcache.php link. Make sure to edit the memcache.php file and update the top configuration related lines first.

Memcached Stats View

Adjusting available RAM for the service

# vi / etc / sysconfig / memcached
PORT = "11211"
USER = "memcached"
MAXCONN = "1024"
CACHESIZE = "64" # change size in MB here

# service memcached restart

Using it in a web application


For WordPress, Memcached is usable in W3 Total Cache and WP-FPC. Using the latter is best in case you don’t have full page cache by other means (i.e. Nginx FastCGI cache). Otherwise, use W3 Total Cache with Memcached.


Joomla supports it natively: instructions to enable Memcached in Joomla.


It is a distributed system so you can install more of its instances on other servers and easily use all of them from within one application.

P. S. checkout the story behind Memcached

Used materials: [1]

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: