Instructions for installing Memcached on CentOS 7

Tutorials 0 lượt xem
Instructions for installing Memcached on CentOS 7 thumbnail
This post is part 6 of 7 in the LEMP for CentOS 7 series

Memcached is also a way to speed up website processing. In particular, Memcached is often combined with the W3 Total Cache plugin as a way to speed up WordPress websites

When talking about Memcached we usually talk about 2 components:

  • Memcached Server: we will install a server that handles how
  • Memcached module: module in PHP to communicate with Memcached server​

The memcached model I mentioned in this post

memcached-architecture

With VPS you have the option of whether you want to use Memcached or not. ShareHost depends on whether the provider has this feature or not?

Today’s article I will guide you to install Memcached on CentOS 7.

Install Memcached server:

First we install the first component of the Memcached system with the following command: ​

yum -y install memcached

The following command to start Memcached: 

systemctl start memcached

To make Memcached run on server restart, use the following command: 

systemctl enable memcached

Use the following command to check if memcached is up and running: 

ps aux | grep memcached

Configure Memcached

The memcached configuration is located in the file /etc/sysconfig/memcached

nano /etc/sysconfig/memcached
install memcached on centos 7

The cachesize part will be the RAM for Memcached. Default is 64MB. Here I increased to 128MB. 

Restart Memcached to use the new configuration. 

systemctl restart memcached

Install the Memcached PHP Module

For Memcached to work with PHP you need to install the Memcached Module

In the series of articles about LEMP on CentOS, I use PHP 7.1, so I will install it with the following command: ​

yum --enablerepo=remi,remi-php71 install php-pecl-memcached php-pecl-memcache

Restart PHP-FPM: systemctl restart php-fpm

Now go to the W3 Total Cache configuration and select Memcached for Page Cache, Database Cache and Object Cache. 

View articles in the series

Previous part: Zend OPcache installation and configuration guide Next part: Let’s Encrypt certificate installation guide on CentOS 7 (NGINX)

Bài viết liên quan