How to Install LiteSpeed Memcached (LSMCD) with OpenLiteSpeed and DirectAdmin

With OpenLiteSpeed installed on your DirectAdmin server, you should be seeing the benefits with a noticeable decrease in your webservers response time (TTFB), increased ability to handle traffic spikes and an increase in WordPress performance with it’s built full-page caching system (LSCache) eliminating the need for a 3rd party plugins.

You can take this a step further and introduce object caching to your server which involves storing database query results so when the query is requested again, it can be served from the cache without the need to repeatedly query the database. Object caching will help to increase the speed of your WordPress website which is heavily dependent upon the database by reducing the load on your website’s database while decreasing the response time of your website and bolstering your website’s ability to scale and handle an increased amount of traffic. The most popular object caching tools are Redis, Memcached and LiteSpeed’s own Memcached (LSMCD) system.

LSMCD is a high-performance, distributed caching system with file-backed shared memory which aids in speeding up dynamic web applications, by providing a fast and powerful in-memory data store that can reduce the load on your website’s MySQL database, while also decreasing the response time of your website and bolstering your website’s ability to scale and handle increased traffic.

Designed as a drop-in replacement for Memcached but offering better performance and scalability than Memcached with improvements and extra feature set such as high-availability which replicates your data across several virtual pools of memory making it available even if one or more of your servers go down and persistence of data where data is retained on the server, even after shutting down, restarting, or even crashing and unlike Memcached, there’s no need for a database backend.

In this guide, we will show you how to install and configure LiteSpeed Memcached (LSMCD) using OpenLiteSpeed and install the required Memcached PHP module in DirectAdmin to enable interaction with the LSMCD memory cache daemon.

Install LiteSpeed Memcached (LSMCD)

Before we install and configure LSMCD, you will need to install the required package dependancies that LSMCD relies upon to work properly using the following command.

yum groupinstall "Development Tools"
yum install autoconf automake zlib-devel openssl-devel expat-devel pcre-devel libmemcached-devel cyrus-sasl*

Now we will need to download LSMCD from LiteSpeed’s Github repository using the following command.

cd ~
wget https://github.com/litespeedtech/lsmcd/archive/master.zip
unzip master.zip

Once the download has completed we will need to compile LSMCD using the following command.

cd $(ls -1d lsmcd-*/ | tail -1)
./fixtimestamp.sh
./configure CFLAGS=" -O3" CXXFLAGS=" -O3"
make

LSMCD should now be compiled. Now we need to install LSMCD using the following command.

sudo make install

With LSMCD successfully installed, we will need to edit the node.conf file to correctly set and bind your IP address. The default configuration file binds to IP address 127.0.0.1 using port 11211 which is suitable for a single server setup, however you will need to adjust this line CACHED.ADDR= if you are using a multi-server system using the following command. In our example, we will be using nano text editor.

nano /usr/local/lsmcd/conf/node.conf
CACHED.ADDR=YOUR_IP_ADDRESS:YOUR_PORT

For more advanced information on configuring the node.conf file, you can refer to the LiteSpeed documentation which explains all configuration options available.

Now LSMCD has been successfully installed and configured we will need to enable and start the daemon using the following command.

systemctl enable lsmcd
systemctl start lsmcd
systemctl status lsmcd

You can verify that LSMCD is running using either of the following commands.

telnet 127.0.0.1 11211
ps aux | grep lsmcd
netstat -pant | grep :11211

That’s it. You have now successfully installed and configured LiteSpeed Memcached (LSMCD) module, started the LSMCD daemon and verified it is running correctly. Now to enable communication with the LSMCD daemon we will need to install the Memcached PHP module to DirectAdmin.

Install Memcached PHP Module

With LSMCD successfully installed we will need to install the required Memcached PHP module to enable communication with the LSMCD daemon. To install the module we will be using a handy script created by the team over at Poralix to aid with the installation of PECL extensions for PHP with DirectAdmin.

Firstly, we will need to download the script from GitHub using the following command.

cd /usr/local/directadmin/scripts/custom
wget https://raw.githubusercontent.com/poralix/directadmin-utils/master/php/php-extension.sh -O php-extension.sh
chmod 750 php-extension.sh

With the script successfully downloaded we now need to install the Memcached PHP module using the following command.

./php-extension.sh install memcached

You can verify the Memcached PHP module using the following command.

./php-extension.sh status memcached

Once you have issued the status command, you should see the following message, dependant upon the version of PHP you have installed.

[root@vpsb custom]# ./php-extension.sh status memcached
[OK] The extension memcached for PHP 73 seems to be enabled!
memcached
memcached support => enabled
memcached.compression_factor => 1.3 => 1.3
memcached.compression_threshold => 2000 => 2000
memcached.compression_type => fastlz => fastlz
memcached.default_binary_protocol => Off => Off
memcached.default_connect_timeout => 0 => 0
memcached.default_consistent_hash => Off => Off
memcached.serializer => php => php
memcached.sess_binary_protocol => On => On
memcached.sess_connect_timeout => 0 => 0
memcached.sess_consistent_hash => On => On
memcached.sess_consistent_hash_type => ketama => ketama
memcached.sess_lock_expire => 0 => 0
memcached.sess_lock_max_wait => not set => not set
memcached.sess_lock_retries => 5 => 5
memcached.sess_lock_wait => not set => not set
memcached.sess_lock_wait_max => 150 => 150
memcached.sess_lock_wait_min => 150 => 150
memcached.sess_locking => On => On
memcached.sess_number_of_replicas => 0 => 0
memcached.sess_persistent => Off => Off
memcached.sess_prefix => memc.sess.key. => memc.sess.key.
memcached.sess_randomize_replica_read => Off => Off
memcached.sess_remove_failed_servers => Off => Off
memcached.sess_sasl_password => no value => no value
memcached.sess_sasl_username => no value => no value
memcached.sess_server_failure_limit => 0 => 0
memcached.store_retry_count => 2 => 2

That’s it. You have now successfully installed and configured LiteSpeed Memcached (LSMCD) module, started the LSMCD daemon, verified it is running correctly and installed the PHP Memcached module to DirectAdmin to enable communication with the LSMCD daemon.

How useful was this guide?

Click on a star to rate it!

Average rating / 5. Vote count:

Be the first to rate this guide.

We are sorry that this guide was not useful for you!

Help us to improve this guide!

Tell us how we can improve this guide?

By VPSBasics

This guide was written by the VPS Basics editorial team, led by Gilberto Van Roosen. They are a unique blend of people, dedicated to providing highly detailed, comprehensive and importantly easy to follow tutorials, written in plain English. They specialise in tutorials for managing Linux servers and its software.

3 Comments for How to Install LiteSpeed Memcached (LSMCD) with OpenLiteSpeed and DirectAdmin

Hi,
Can’t install using this exact guide. Having this error while installing PHP extension.

checking for memcached msgpack support… disabled
checking for libmemcached location… configure: error: memcached support requires libmemcached. Use –with-libmemcached-dir= to specify the prefix where libmemcached headers and library are located
[ERROR] Configure of memcached failed
[ERROR] Could not find /usr/local/php73/lib/php/extensions/no-debug-non-zts-20180731/memcached.so. Removing extension from /usr/local/php73/lib/php.conf.d/50-webapps.ini

Could you please help me with this?

Hi Ryan

This error [ERROR] Could not find /usr/local/php73/lib/php/extensions/no-debug-non-zts-20180731/memcached.so would suggest that the Memcached PHP module isn’t installed on your server. Check to make sure that Memcached is installed using php -m | grep -i memcached. If it is not installed, just install using the script from Poralix at the bottom of the tutorial and restart LSMCD using systemctl stop lsmcd && systemctl start lsmcd && systemctl status lsmcd.

Hope that helps.
VPSBasics

Join the Conversation

Note: Your email address will not be published when posting a comment.

Note: All comments are held for moderation and are reviewed by our editorial team prior to approval.

VPSBasics uses Akismet anti-spam filters to reduce spam across our website. Our website is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply. Learn how your data is processed.