Login to WHM as user root, go to Terminal or login to SSH as user root. Then run the command
yum install memcached
Enable memcached to start on boot.
systemctl enable memcached
Configure memcached
Default configuration on AlmaLinux 9 look like the following
PORT="11211" USER="memcached" MAXCONN="1024" CACHESIZE="64" OPTIONS="-l 127.0.0.1,::1"
edit configuration file
vi /etc/sysconfig/memcached
Lets change cache size to 128 mb
Find
CACHESIZE="64"
Replace 64 with 128
In AlmaLinux 9, memcached only listen on loop back interface IP address (127.0.0.1,::1). If your configuation don’t restrict memcache to listen to 127.0.0.1, change your options line as follows.
OPTIONS="-l 127.0.0.1 -U 0"
This will restrict memcached to listen on IP address 127.0.0.1 and -U 0 disable UDP. This is done to protect memcachd installation from attacks.
Restart memcached with
systemctl restart memcached
To verify memcached is running, run
[root@server1 ~]# netstat -lntp | grep memc tcp 0 0 127.0.0.1:11211 0.0.0.0:* LISTEN 2224258/memcached [root@server1 ~]#
We have memcached listening on 127.0.0.1:11211
Now we have memcached deamon running. We need PHP module installed.
Installing memcached PHP module
To list all available memcached PHP module, run
yum search php-memcached
To install memcache module for PHP 8.2, run
yum install -y ea-php82-php-memcached
For PHP 8.0, install package ea-php80-php-memcached, similarly, for PHP 8.1 install ea-php81-php-memcached.
If you use CloudLinux PHP selector, memcached is already installed on the system. You can enable the module using PHP Selector.
Back to memcached
Leave a Reply