Instructions for installing Memcached on DirectAdmin

What is Memcache?

Memcached is a cache system that works by temporarily storing information about the data you use often in RAM. Because the read and write speed of memory is always higher than that of file storage, the use of memcached significantly speed up your system.

Memcached’s operating model:

1. Install Memcached

Install the Memcached package

yum install memcached

You should note that there are two memcache packages that exist, memcache and memcached (with the d at the end) as well as two versions of the PHP Extension Module, respectively, php-pecl-memcache and php-pecl-memcached. We will use the 2nd version (with the letter d) because it is stable and supports more functions.

2. Configure Memcached

The most important parameter you need to note is the CACHESIZE, the unit of measurement is MB. For example, below I use 128MB to cache (default 64MB). OPTIONS security configuration only allows local connect to port 11211 only.

vi /etc/sysconfig/memcached

PORT="11211" USER="memcached" MAXCONN="10240" CACHESIZE="128" OPTIONS="-l"

Start Memcached

chkconfig memcached on

service memcached start

Step 1: Check if the memcached service is available on the server

service memcached status

Step 2: Check if php-memcached is integrated

php -m | grep memcache

* : If nothing, install php-memcache

Step 3: Install php-memcache

Install support packages for the installation

yum install php-devel php-pear -y

Install php-memcache

yum install libmemcached-devel
pecl install memcache

Bước 4 : enable memcache

– Check the path of the php.ini file with the command:

php -i | grep php.ini

include the memcache module in php.

By Nguyen Manh Cuong

Nguyen Manh Cuong is the author and founder of the nguyendiep blog. With over 14 years of experience in Online Marketing, he now runs a number of successful websites, and occasionally shares his experience & knowledge on this blog.

Leave a comment

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