Install Memcached with Apache on Centos 6/7

Memcached is a general-purpose distributed memory caching system. It is often used to speed up dynamic database-driven websites by caching data and objects in RAM to reduce the number of times an external data source must be read. Memcached is free and open-source software, licensed under the Revised BSD license

yum install memcached

Configure memcache config file

vi /etc/sysconfig/memcached

# Running on Port 11211


# Start as memcached daemon


# Set max simultaneous connections to 1024


# Set Memory size to 2048 – 4GB(4096)


#Set server IP address


chkconfig –levels 235 memcached on

Use below for centos 7

systemctl enable memcached

service memcached start

To stop and check status, use the following commands

service memcached stop

service memcached status

Verify Memcached

Use netstat command to verify Memcached is running.

# netstat -tulpn | grep :11211

tcp        0      0   *                   LISTEN      20775/memcached

udp        0      0   *                               20775/memcached

Check the stats of the server using memcached-tool.

memcached-tool stats

# yum install php-pecl-memcache

Install Memcached Perl Library

Install perl library for Memcached.

# yum install perl-Cache-Memcached

Install Memcached Python Library

Install python library for Memcached.

# yum install python-memcached

Restart Apache

Restart the Apache service to reflect changes.

# /etc/init.d/httpd restart
OR on Centos 7
# systemctl restart httpd

Leave a Reply