In the previous lesson, you have learned about getting yourself to know whether the Memcached service on your server is installed and listening to Port 11211.
Now this lesson is on checking the presence of the required PHP libraries needed to make Memcached work for you.
You can verify the installation from SSH. Another important thing is to make sure to use the same version of PHP as the website you want to use Memcached on.
On a dedicated server having WHM/cPanel with PHP version 7.3, the following command is used with the output as shown:
[root@server[~]: ea-php73 -i | grep "memcached" /opt/cpanel/ea-php73/root/etc/php.d/memcached.ini, memcached memcached support => enabled
Verifying Memcached service & PHP libraries are working
From the command line, telnet to the Memcached service.
[root@server ~]# telnet localhost 11211
This output will be returned, and you will be connected to the Memcached service.
Trying ::1... telnet: connect to address ::1: Connection refused Trying 127.0.0.1... Connected to localhost. Escape character is '^]'.
Enter the command stats. A full page of output will appear, but towards the middle, look for the lines STAT bytes_read and STAT bytes_written.
stats STAT pid 6374 STAT uptime 37567 ... ... STAT bytes_read 3733268975 STAT bytes_written 6526192728 STAT limit_maxbytes 1073741824 ... ... END
When you see a big amount of data is read and written, that means Memcached is working.
Entering the command stats again is going to show changes to these values.
And when you are seeing a very tiny amount of data read and written, or the values of 0, that means Memcached is not functioning good.
stats STAT pid 30601 STAT uptime 603941 ... ... STAT bytes_read 7 STAT bytes_written 0 STAT limit_maxbytes 1073741824 ... ... END
Use quit to return to a standard prompt.
quit Connection closed by foreign host. [root@server ~]#
So that is how you can know that the caching is working as expected.