Instructions to install Memcached on CentOS 7 install HocVPS

Tutorials 0 lượt xem
This post is part 3 of 3 in the Using HocVPS . series

Previously, I had a post about activating Memcached on a Shared Host that supports Memcached like HawkHost .

Today I will cover installing Memcached on a Linux server.

Specifically, I will give you the most complete guide on installing Memcached. Includes installation of memcached server. The Memcached module in PHP 7.1.

In addition, I will guide you to choose which WordPress plugin to work with the memcached server.

The article will apply to Linux servers with HocVPS installed. You can apply the techniques in this article to any Linux server with CentOS installed.

HocVPS also has a tutorial on installing Memcached on CentOS.

This article will focus on a specific solution: CentOS 7 + PHP 7.1 + WordPress website.

A Memcached system will include: memcached server, memcached module in PHP and a WordPress plugin that supports memcached.

Step 1: Install Memcached

First we will install the memcached server.

You run the following command:

The following command to start the Memcached server:

To have Memcached run on server restart, run the following command:

Configure Memcached

The memcached configuration is located in the  file  /etc/sysconfig/memcached . You open this file with the nano editor in Linux. (if nano is not installed, install it with the familiar yum install nano command)

This is the default configuration:

install memcached on centos 7

You can change the configuration as follows: (increase cache size to 128MB, options only allow connections to local via port 11211).

To monitor memcached status, you should install a tool like phpMemcachedAdmin. 

Installing this tool is quite simple. You just need to download, unzip and use it right away.

Here I will install to the private_html directory of the main domain that I provide when installing HocVPS:

Now you access the tool at: http://your_ip_address:port/memcached

The main port is the admin port you choose when installing HocVPS. 

install memcached on Linux server with HocVPS 1

As shown above, the first time you access it, you get an error:  Error : Configuration file or folder is missing, please fix this error and try again

Go to Edit Configuration . Click Save Live Configuration . It’s done.

install memcached on a Linux server with HocVPS 2

Step 2: Install the Memcached PHP Module

You need to install the Memcached PHP Module with the following command:

Restart PHP and Nginx:

Step 3: Install the WordPress plugin

I will cover all the common situations here.

Case 1:

You use the W3 Total Cache plugin .

W3 Total Cache supports Memcached so simply do the following:

Go to Performance . In Page Cache , Database Cache and Object Cache you just need to select Memcached. Click the Save Settings & Purge Caches button . It’s done. No additional configuration required.

Remember to check your cache usage using the phpMemcachedAdmin tool above.

Case 2:

In case you use a cache plugin that doesn’t support Memcached like WP Rocket , LiteSpeed ​​Cache (when you install OpenLiteSpeed ​​web server )

In this case, you need to install an additional Memcached Is Friend plugin . (This plugin is on GitHub, see how to install HERE )

You just need to install and activate the plugin. Then go to Tools -> Memcached , see a message like this is successful:

install memcached on Linux server with HocVPS 3

If you don’t want to use Memcached, use the following command to delete it:

Good luck!

View articles in the series

Previous part: How to simply install Let’s Encrypt certificate on VPS using HocVPS

Bài viết liên quan