Introduction
The procedure below will guide you on installing and configuring Memcached.
Procedure
Install and enable Memcached:
1. Connect to the server via SSH as root or navigate to WHM >> Server Configuration >> Terminal.
2. Run the following command:
yum -y install memcached
3. Enable memcached in systemd by running the following command:
systemctl enable memcached
Create a secure Memcached configuration in systemd:
By default, Memcached will accept connections from everyone which is frequently exploited in distributed denial of service attacks. To prevent this, follow the steps listed below. If you are unfamiliar with editing a file on the command-line, please see: How to edit a file on command-line
1. Open the /etc/sysconfig/memcached file using any command-line text editor, such as vi, vim, or nano.
Example:
vi /etc/sysconfig/memcached
2. Find the line that starts with “OPTIONS=” and edit the line to look like this:
OPTIONS="-l 127.0.0.1 -U 0"
3. Restart Memcached by running the following command:
systemctl restart memcached
4. Confirm Memcached is running by running the following command:
systemctl status memcached
Install Memcached PHP Extensions
The Memcached PHP extensions can be installed using WHM >> Software >> EasyApache 4. Please see: How to install a PHP extension in WHM
Once the Memcached PHP extensions have been installed, restart Memcached by running the following command:
systemctl restart memcached
More information on installing and configuring Memcached in cPanel can be found here:
cPanel Blog – Memcached PHP Applications for Faster Web Apps