Hosting Question? Find the Solution -

KNOWNHOST KNOWLEDGE BASE

Browse our Guides, Articles, and How-To's

How to install Memcached on DirectAdmin?

Category: DirectAdmin
Tags: # # #

Nowadays, DirectAdmin itself comes with all the required PHP extensions installed with the initial installation. But, to enhance the usability of the DirectAdmin control panel or improve the server’s performance, you might need specific more extensions such a Memcached, Redis, etc. Learn, How to install Memcached on DirectAdmin?


You might know that Memcached is used for mostly object caching along with caching of following elements,

  • Database queries.
  • Sessions.
  • Web Pages.
  • API Caching.
  • Meta Data.

The advantage of using Memcached is to improve the work loading capacity of the server. Also, requests served through caching lead to tremendous performance increases.

Let’s get started with Memcached installation on DirectAdmin server.


Install memcached & libmemcached

Installation of Memcached.

First, install the Memcached package, and its -dev package using the following commands,

yum install memcached
yum install memcached-devel

Installation of Memcached library (libmemcached).

Memcached requires the library to make it work properly. To install the Memcached library package and its -dev package, run the following commands,

yum install libmemcached-devel
yum install libmemcached

You have successfully installed the Memcached on the directadmin server. To verify that run the following command,

systemctl status memcached

You must get the output of the above command something like Memcached service status as ACTIVE,

[root@host ~]# systemctl status memcached
* memcached.service - Memcached
   Loaded: loaded (/usr/lib/systemd/system/memcached.service; disabled; vendor preset: disabled)
   Active: active (running) since Mon 2021-10-11 03:37:19 EDT; 14min ago
 Main PID: 29231 (memcached)
   CGroup: /system.slice/memcached.service
           `-29231 /usr/bin/memcached -u memcached -p 11211 -m 64 -c 1024

Oct 11 03:37:19 host.kh-demo.com systemd[1]: Started Memcached.

Install Memcached PHP Extension

DirectAdmin has scripts with which you can easily install the required extension per PHP version-wise.

Syntax of the command,

/usr/local/php<version>/bin/pecl install <extension name>

Let us install Memcached PHP Extension for installed php versions (Example: 5.6, 7.2, 7.4) using following command,

/usr/local/php56/bin/pecl install memcached
/usr/local/php72/bin/pecl install memcached
/usr/local/php74/bin/pecl install memcached

Nexa, add extension=memcached in to php.ini.

echo "extension=memcached" > /usr/local/php56/lib/php.conf.d/memcached.ini
echo "extension=memcached" > /usr/local/php72/lib/php.conf.d/memcached.ini
echo "extension=memcached" > /usr/local/php74/lib/php.conf.d/memcached.ini

Finally, restart the php service.

systemctl restart php-fpm56
systemctl restart php-fpm72
systemctl restart php-fpm74

You can verify the changes using following command,

/usr/local/php<version/bin/php -m | grep memcached

Conclusion

Now that we’ve gone over how to install Memcached on the DirectAdmin server. This article is an administrative tutorial, and you must need root-level access to perform described actions. If you can’t find the Memcached enabled of the server, then get in touch with the administrator.

KnownHost offers 365 days a year, 24 hours a day, all 7 days of the week best in class technical support. A dedicated team ready to help you with requests should you need our assistance. You’re not using KnownHost for the best webhosting experience? Well, why not? Check with our Sales team to see what can KnownHost do for you in improving your webhosting experience.