How to Install and Configure Memcached on DirectAdmin for WordPress Performance

Priya

Content Writer & Researcher

Last Updated: 20 September 2026
How to Install and Configure Memcached on DirectAdmin for WordPress Performance
🖥️

Speed Up WordPress on DirectAdmin With Expert Memcached Configuration

CloudHouse Technologies installs and tunes Memcached for your DirectAdmin hosting environment — reducing MySQL load, cutting page generation time, and improving TTFB across all your WordPress sites.

🖥️12,400+PCs Fixed
⭐4.9★Google Rating
⚡<15 minAvg. Response
🛡️ISO 27001Certified

Every WordPress page load triggers dozens of MySQL database queries. Without object caching, those queries run every single time — even for identical requests. Memcached solves this by storing the results of expensive database queries in RAM, allowing WordPress to retrieve them in under a millisecond instead of hitting MySQL each time. This guide covers the complete setup of Memcached on DirectAdmin servers: installation, PHP extension configuration, WordPress object cache configuration, and performance verification.

What Memcached Does and When to Use It

Memcached is a distributed in-memory key-value store that acts as a caching layer between WordPress and MySQL. Instead of running a query like "get all posts in category X with their metadata", WordPress stores the result in Memcached RAM and retrieves it from memory on the next request — bypassing MySQL entirely.

Best use cases for Memcached on DirectAdmin:

  • WordPress sites with high database query counts (WooCommerce, membership sites, forums)
  • Servers where MySQL CPU usage is consistently above 30-40%
  • Sites using page caching (Memcached handles object-level caching, page caches handle full-page caching — they complement each other)
  • Multi-site WordPress installations

Memcached vs Redis: Both are in-memory caches. Redis supports data persistence (data survives restarts) and more data structures, making it better for session storage and advanced caching. Memcached is simpler, uses less RAM per cached object, and is often faster for pure object caching workloads. Choose Memcached if you already have it on your DirectAdmin server or prefer a lighter footprint; choose Redis if you need persistence or are already using it for sessions.

💡 None of these worked? Skip the guesswork.

Get Expert Help →

Step 1: Install Memcached on DirectAdmin

DirectAdmin runs on CentOS, AlmaLinux, CloudLinux, or Debian/Ubuntu. Installation differs slightly by OS.

CentOS / AlmaLinux / CloudLinux

1Install Memcached and development libraries
yum install -y memcached libmemcached libmemcached-devel
2Start and enable Memcached
systemctl start memcached
systemctl enable memcached
3Verify Memcached is running
systemctl status memcached
# Expected output includes: Active: active (running)

Debian / Ubuntu

1Install Memcached
apt-get update
apt-get install -y memcached libmemcached-tools
2Start and enable
systemctl start memcached
systemctl enable memcached
1Edit the Memcached configuration file

On CentOS/AlmaLinux: /etc/sysconfig/memcached

On Debian/Ubuntu: /etc/memcached.conf

2Set memory limit and bind to localhost

For CentOS/AlmaLinux (/etc/sysconfig/memcached):

PORT="11211"
USER="memcached"
MAXCONN="1024"
CACHESIZE="256"
OPTIONS="-l 127.0.0.1"

For Debian/Ubuntu (/etc/memcached.conf):

-m 256
-l 127.0.0.1
-p 11211

Memory sizing guide:

  • Low traffic WordPress (under 5,000 visits/day): 64-128 MB
  • Medium traffic (5,000-50,000 visits/day): 256 MB
  • High traffic (50,000+ visits/day or WooCommerce): 512 MB — 1 GB

Security note: Always bind Memcached to 127.0.0.1 (localhost), never to a public IP. Memcached has no built-in authentication and is a common DDoS amplification vector if exposed publicly.

3Restart Memcached to apply changes
systemctl restart memcached
1Navigate to CustomBuild directory
cd /usr/local/directadmin/custombuild
2Check available PHP versions
./build versions | grep php
3Enable Memcached in CustomBuild options
# Check current options for PHP 8.2 (or your version):
cat options.conf | grep memcache
4Build the Memcached extension
./build php n
# or for a specific version:
./build php82_memcached

Manual Install via PECL or Package Manager

If CustomBuild does not cover your setup:

# Install php-memcached via yum (CloudLinux/cPanel-style repos):
yum install -y ea-php82-php-memcached

# Or via PECL:
pecl install memcached

# Enable the extension (add to php.ini or a conf.d file):
echo "extension=memcached.so" > /etc/php.d/memcached.ini
1Verify the extension is loaded
php -m | grep -i memcach

You should see memcached in the output.

2Verify from a PHP script
php -r "var_dump(class_exists('Memcached'));"
# Expected: bool(true)
1Basic telnet test
telnet 127.0.0.1 11211
# In the Memcached session:
stats
# You will see output with curr_connections, cmd_get, cmd_set, etc.
quit
2PHP connectivity test

Create a test file at /var/www/vhosts/yourdomain.com/httpdocs/memcache_test.php:

<?php
$m = new Memcached();
$m->addServer('127.0.0.1', 11211);
$m->set('test_key', 'memcached_working', 60);
$result = $m->get('test_key');
echo ($result === 'memcached_working') ? 'SUCCESS: Memcached is working' : 'FAILED: Memcached not responding';
?>

Access it via browser. Delete the file after testing — it should not be left on production.

3Check stats via memcached-tool
memcached-tool 127.0.0.1:11211 stats
1Check Memcached hit rate
memcached-tool 127.0.0.1:11211 stats | grep -E "cmd_get|get_hits|get_misses"

After several page loads, the get_hits number should be climbing. Calculate hit rate:

Hit Rate = get_hits / (get_hits + get_misses) * 100

A healthy hit rate for WordPress object caching is above 80%. Low hit rates may indicate the cache is too small or keys are expiring too quickly.

2Check memory usage
memcached-tool 127.0.0.1:11211 stats | grep bytes
# curr_bytes: current memory in use
# limit_maxbytes: your configured limit

If curr_bytes approaches limit_maxbytes, increase Memcached's memory allocation.

3Measure database query reduction

With the Query Monitor plugin active, check the Database tab before and after Memcached. A well-configured object cache typically reduces database queries by 40-80% on repeat requests.

Step 7: DirectAdmin Multi-PHP Version Considerations

If you run multiple PHP versions on your DirectAdmin server (e.g., PHP 7.4 and PHP 8.2 for different domains), the Memcached extension must be installed for each PHP version your WordPress sites use.

# Check which PHP version each domain uses:
cat /usr/local/directadmin/data/users/username/domains/yourdomain.com.conf | grep php

# Build Memcached extension for additional PHP versions:
cd /usr/local/directadmin/custombuild
./build php74_memcached
./build php82_memcached

After building, restart PHP-FPM for each version:

systemctl restart php74-fpm
systemctl restart php82-fpm

Troubleshooting Common Memcached Issues on DirectAdmin

PHP extension not loading: Run php -m | grep memcach — if empty, the extension is not installed for the active PHP CLI version. Check /etc/php.d/ or /usr/local/lib/php.ini for the extension directive.

WordPress not using Memcached after plugin setup: Check that a object-cache.php drop-in file is NOT already in wp-content/ — a conflicting drop-in from another plugin overrides your setup.

Memcached evicting too aggressively: Increase CACHESIZE in the Memcached config. You can also reduce cache lifetime (TTL) values in W3 Total Cache to keep only fresh, frequently-used objects.

Port 11211 not responding: Confirm Memcached is bound to 127.0.0.1 and running: ss -tlnp | grep 11211

For expert performance tuning of DirectAdmin servers including Memcached, OPcache, PHP-FPM, and database optimization, CloudHouse Technologies provides professional server management with a focus on WordPress hosting performance.

Get the Free Linux Server Admin Cheatsheet (PDF)

Essential commands for server management, networking, and troubleshooting — all on one printable page.

Running Linux servers? Let us manage them for you.

Our Managed Linux Server plans cover updates, security hardening, monitoring, and 24/7 incident response — so your servers stay up and your team stays focused.

  • Proactive OS patching and security updates
  • 24×7 monitoring with instant alerting
  • Backup configuration and disaster recovery
  • Dedicated Linux engineers on call
See Pricing Plans →

What our customers say

“Our production server went down at 2 AM. CloudHouse had it back online in under 20 minutes. Incredible response time.”

Arun S.

CTO, SaaS Startup

“They migrated our entire infrastructure from Ubuntu 18 to 22 with zero downtime. Couldn't have asked for better.”

Deepak N.

DevOps Lead

Frequently Asked Questions

DirectAdmin does not bundle Memcached, but it is fully supported. You install Memcached at the OS level (yum install memcached or apt-get install memcached), then install the PHP Memcached extension via DirectAdmin's CustomBuild system or PECL. Once both are installed, WordPress can use Memcached as its object cache backend through a plugin or the object-cache.php drop-in.

Need this done for you?

Website Development

Fast, SEO-ready websites built to generate enquiries.

Learn more

Book your free 15-minute diagnosis

A certified technician will call you back within 15 minutes during business hours.

Share this article

Leave a Comment

Comments (0)

Loading comments...