Installing Memcached on CentOS and DirectAdmin for WordPress · vanrossum.dev    

       vanrossum.dev 

 Article

Installing Memcached on CentOS and DirectAdmin for WordPress
============================================================

 ![](https://vanrossum.dev/images/jeffrey-portrait.webp) By Jeffrey van Rossum

  vanrossum.dev  

  [      vanrossum.dev ](https://vanrossum.dev)                      

  [ ← Writing ](https://vanrossum.dev/posts)   [ ← Writing ](https://vanrossum.dev/posts) [ Install memcached ](#install-memcached) [ Install PHP extension ](#install-php-extension) [ Using memcached with WordPress ](#using-memcached-with-wordpress) 

This article will go through the steps to get Memcached installed on a Centos (7 or 8) server with DirectAdmin.

I needed to install Memcached to make use of object caching in WordPress on a VPS. The VPS was hosting one website with the object cache stored on disk at the time. Using Memcached would be more performant.

Make sure to run most of the commands as root.

Install memcached
-----------------

Run the following to install Memcached.

```bash
yum install memcached
yum install memcached-devel
yum install libmemcached-devel
yum install libmemcached

```

If you would like to modify the configuration of memcached, you can find the config file at the following location:

```bash
nano /etc/sysconfig/memcached

```

For security tips check out [this article](https://www.digitalocean.com/community/tutorials/how-to-install-and-secure-memcached-on-centos-7) at DigitalOcean.

Install PHP extension
---------------------

I like to use a [custom PHP extension script](https://help.poralix.com/articles/install-pecl-extension-for-php-directadmin-server) for DirectAdmin. This makes it easy to install extensions for PHP on DirectAdmin. Follow the steps in that article listed under "Let's start".

Once you can run the php-extension.sh script, run the following to install the memcached extension:

```bash
./php-extension.sh install memcached

```

Then check if the extension has been installed by running:

```bash
./php-extension.sh status memcached

```

Restart your server for the extension to be recognized. You might have to restart memcached after your server has restarted.

```bash
systemctl restart memcached

```

Using memcached with WordPress
------------------------------

To make WordPress use Memcached, consider installing the [Memcached Redux plugin](https://wordpress.org/plugins/memcached-redux/). Note that the installation of this plugin is different from how you'd regularly install plugins.

Instead of activating the plugin, place the `object-cache.php` file inside your `wp-content` folder.

  ![](https://vanrossum.dev/images/jeffrey-portrait.webp) Jeffrey van Rossum [@jeffreyrossum](https://x.com/jeffreyrossum) 

 share [𝕏](https://twitter.com/intent/tweet?url=https%3A%2F%2Fvanrossum.dev%2Fposts%2Finstalling-memcached-on-centos-and-directadmin-for-wordpress&text=Installing+Memcached+on+CentOS+and+DirectAdmin+for+WordPress) [WhatsApp](https://wa.me/?text=Installing+Memcached+on+CentOS+and+DirectAdmin+for+WordPress+https%3A%2F%2Fvanrossum.dev%2Fposts%2Finstalling-memcached-on-centos-and-directadmin-for-wordpress) [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fvanrossum.dev%2Fposts%2Finstalling-memcached-on-centos-and-directadmin-for-wordpress) 

   © 2026 Jeffrey van Rossum 

  vanrossum.dev vanrossum.dev
