• Indonesian
  • English
  • Configure Memcached on cPanel LiteSpeed: Step-by-Step 2026

    Kecepatan:
    ⏱ 10 min read

    Skip the small talk. If you run a cPanel server with LiteSpeed and a WordPress site that keeps hammering the database, Memcached is the fix. Here’s the complete setup, step by step, in the order you should run it.

    By the end you’ll have: the Memcached daemon running, the PHP extension loaded, LiteSpeed Cache wired to it, and hard proof that cache hits are actually happening. No fluff. Just commands.

    Difficulty: Intermediate
    Last Updated: July 2026
    Tested On: cPanel 124, AlmaLinux 9, LiteSpeed Web Server 6.3, PHP 8.1/8.2

    Why Configuring Memcached on cPanel Matters

    You’re here for one of two reasons. Either your WordPress site is slow, or you’re building a new server and want to do it right the first time. Both are valid, and the setup is the same either way. It’s like setting up the shelf at the front of your workshop — you only do it once, but it saves you a walk to the back room on every single job after that.

    The problem with most WordPress sites on cPanel is repetition. Every page load runs the same dozen or so database queries, over and over, whether the answer changed or not. MySQL eats the load, query time climbs, and visitors feel it as slow pages. LiteSpeed Cache already handles page caching, but object cache — the layer that stores query results in RAM — is a separate component, and it’s the one most setups are missing.

    This is the part everyone skips. They tune MySQL, they bump PHP settings, they upgrade the VPS. But the real bottleneck is usually an unconfigured object cache. Memcached keeps query results in memory so MySQL doesn’t answer the same question five hundred times. Get this configured properly and you can cut database load by 70-80% on a typical WordPress workload. That’s not a sales pitch — the get_hits counter will prove it to you within an hour of enabling it.

    So here’s the roadmap: install the daemon, configure it safely, load the PHP extension, point LiteSpeed Cache at it, then verify. Fifteen minutes, done.

    Prerequisites

    You need root-level WHM access. Memcached is a server-level service; a plain cPanel account can’t install it. If you only have cPanel access, forward this guide to your host and let them run the install.

    First, check whether Memcached already exists:

    systemctl status memcached

    If you see “Unit memcached.service could not be found”, proceed to Step 1. If the service is already active, skip to the PHP extension step.

    Then check the PHP side:

    php -m | grep -i memcached

    Empty output means the extension isn’t loaded. We’ll fix that in Step 3.

    Step 1: Install Memcached via EasyApache4

    The cleanest path on cPanel is EasyApache4:

    1. Log into WHM.
    2. Go to EasyApache4, under Software.
    3. Open the “Customize” tab and select the PHP profile you’re using.
    4. Click “Additional Packages”.
    5. Check both memcached and php-pecl-memcached.
    6. Click “Review and Install” and confirm.

    Both packages matter, and here’s why. memcached is the daemon that actually stores data in memory. php-pecl-memcached is the PHP extension that lets your application talk to that daemon. Install one without the other and nothing works — you’ll either get “Class ‘Memcached’ not found” or a PHP that simply can’t reach the service.

    The install takes a few minutes. Let it finish; interrupting EasyApache4 mid-build is a fast way to break your PHP profile.

    If you prefer the terminal:

    yum install memcached php-pecl-memcached -y

    On a cPanel box, EasyApache4 is the safer route because it keeps PHP builds consistent with what WHM expects. Reach for the command line only if you know exactly what you’re doing.

    Step 2: Configure the Memcached Daemon

    On RHEL-family systems — CentOS, AlmaLinux, Rocky, CloudLinux, the usual suspects under cPanel — the config lives in /etc/sysconfig/memcached. Open it:

    nano /etc/sysconfig/memcached

    It looks like this:

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

    Two settings deserve your attention:

    • CACHESIZE: how much RAM Memcached may use, in MB. Start at 128MB on a small VPS, 256-512MB on bigger boxes with real traffic. Don’t overshoot. Memcached won’t pre-allocate the whole amount, but a huge limit combined with a memory pressure event can push the OOM killer to start shooting other processes.
    • OPTIONS “-l 127.0.0.1”: bind Memcached to localhost only. This is non-negotiable. Memcached has zero built-in authentication. If it’s reachable from the internet, anyone can read whatever’s in your cache — and it’s a well-known vector for reflection attacks. Bind to localhost, or if you genuinely need cross-server access, protect it with a firewall and a VPN or tunnel.

    This is the classic screw-up: the daemon runs fine, so nobody notices it’s bound to 0.0.0.0 until the server suddenly gets hammered by an amplification scan. Bind to localhost first, ask questions later.

    Save the file, then restart and enable the service:

    systemctl restart memcached
    systemctl enable memcached

    Verify it’s actually listening:

    systemctl status memcached
    ss -tulpn | grep 11211

    Expected result: the service is active, and port 11211 is listening on 127.0.0.1 only. Anything else means the config didn’t take.

    configure memcached on cpanel litespeed

    Step 3: Load the PHP Extension

    This is where most setups quietly fail. The daemon is running, but PHP can’t talk to it because the extension was never loaded into the active PHP build.

    Check it:

    php -m | grep -i memcached

    You want to see “memcached” in the output. If you don’t, the package didn’t land in the profile EasyApache4 is actually using. Go back and confirm php-pecl-memcached is checked for the right profile.

    One LiteSpeed-specific catch: the web server doesn’t run PHP through Apache’s handler. It uses its own lsphp. Make sure the PHP version selected in WHM → MultiPHP Manager is the same one that got the extension. Version mismatch here is the number-one cause of “extension installed but not working”.

    Fastest way to confirm end-to-end: drop a phpinfo file into the site root:

    echo '<?php phpinfo(); ?>' > /home/USER/public_html/phpinfo.php

    Open https://yourdomain.com/phpinfo.php in a browser and look for the “memcached support” section. If it’s there, PHP and Memcached are talking. Delete the file when you’re done — a public phpinfo leaks server details you don’t want strangers to have.

    Step 4: Point LiteSpeed Cache at Memcached

    Now the WordPress side. This takes about sixty seconds:

    1. Open the WordPress admin dashboard.
    2. Go to LiteSpeed Cache → General.
    3. Scroll to the “Object Cache” section.
    4. Set the method to Memcached.
    5. Enter host 127.0.0.1 and port 11211.
    6. Save, then hit “Enable” under Object Cache.

    That’s it. LiteSpeed drops object-cache.php into wp-content/ and every WordPress request starts talking to Memcached through it. You can confirm the drop-in is active on the same page — the status should read “Enabled” with hit and miss counters ticking.

    If you’re running another caching plugin that ships its own object cache — W3 Total Cache, WP Rocket, WP Super Cache — disable theirs first. Two object caches means two drop-in files fighting over the same keys. The result is a slower site than if you’d configured nothing at all. One object cache. Pick one.

    Official reference: LiteSpeed Cache for WordPress documentation.

    Step 5: Prove It’s Working

    Trust, but verify. From the terminal:

    printf 'statsrn' | nc 127.0.0.1 11211

    The output is long, but watch these fields:

    • STAT bytes — how much data is currently cached
    • STAT get_hits — requests served straight from cache
    • STAT get_misses — requests that fell through to MySQL
    • STAT curr_items — number of items in the cache

    Hit ratio is get_hits divided by total requests. After a few hours of normal traffic, a healthy site sits above 90%. If it’s stuck well below that, either the drop-in never got created or the cache lifetime is set too long.

    For a live monitor:

    watch -n 2 'printf "statsrn" | nc 127.0.0.1 11211 | grep -E "get_hits|get_misses"'

    Now refresh your site a few times and watch get_hits climb on every reload. If it doesn’t move at all, something in the chain is broken — go back through Steps 2-4.

    Quick Troubleshooting

    If it’s not working on the first pass, here’s the short list of what’s usually wrong. Save it for later, you’ll probably need it:

    Error / Symptom Cause Fix
    Class ‘Memcached’ not found PHP extension not enabled Check php -m | grep memcached; reinstall php-pecl-memcached via EasyApache4
    Failed to connect to Memcached Daemon down or wrong bind systemctl status memcached; check /etc/sysconfig/memcached
    Connection refused on 11211 Memcached not listening ss -tulpn | grep 11211; confirm PORT=”11211″
    Site slower after enabling Duplicate object cache / plugin conflict Disable other object caches; keep a single drop-in
    LiteSpeed Cache shows “Disconnected” Wrong host/port or PHP extension mismatch Host 127.0.0.1, port 11211; verify active lsphp handler version

    ⚠️ SECURITY WARNING: Back Up Before Continuing

    Before editing /etc/sysconfig/memcached or restarting the service on a production server:

    1. Back up the config: cp /etc/sysconfig/memcached /etc/sysconfig/memcached.bak
    2. Note the current settings in case you need to roll back
    3. Confirm you’re on the right server before making any change

    Restarting Memcached flushes the cache. Every client currently writing to it will fall back to the database until it warms up again — expect a short spike in DB load right after.

    Pro Tips & Warnings

    A few things I wish someone had told me sooner:

    • Memcached is ephemeral by design. Restart the daemon and the cache is gone — expect a short load spike on MySQL while it warms back up. Schedule restarts for quiet hours.
    • Monitor hit ratio, not just cache size. A 512MB cache with a 40% hit ratio is worse than a 128MB cache at 95%. Tune toward the ratio, not toward raw memory.
    • Don’t put the cache and MySQL on the same VPS without watching RAM. Combined, they can crowd each other out. If you’re at 90%+ memory pressure, reduce CACHESIZE.
    • If you ever move to a multi-server setup, keep Memcached behind a firewall or switch to Redis over TLS. Plain Memcached has no encryption.

    FAQ

    Q: Memcached or Redis — which one should I use?

    Both are in-memory object caches. Redis is more feature-rich (more data structures, optional persistence) and Memcached is simpler and lighter for straightforward use cases like WordPress object caching. LiteSpeed Cache supports both. If you already run Redis, use it. If you want the simplest setup, Memcached is plenty.

    Q: What CACHESIZE should I set for my VPS?

    Start with 10-15% of total RAM and watch the stats. A 2GB VPS can start at 256MB; a 1GB VPS is fine at 128MB. Don’t let Memcached eat all your RAM — the OOM killer will step in and kill unrelated processes. Watch free -h and the get_hits/get_misses counters.

    Q: Do I need to restart LiteSpeed after installing Memcached?

    Not if the PHP extension is already loaded in the lsphp handler. If you installed the extension after LiteSpeed started, restart LiteSpeed (or at least PHP) so the extension gets picked up. In WHM: Home → Restart Services → LiteSpeed Web Server.

    Q: Is it safe to expose Memcached to the public?

    No. Never. Memcached has no authentication. Exposed, anyone can read your cached data — which sometimes includes sensitive payloads — and it’s a known vector for amplification attacks. Keep it bound to 127.0.0.1. For cross-server access, use a firewall and a VPN or tunnel.

    Related Reading

    If you’re in this area, these will help:

    Author: Syslog Solutions — NOC & Server Management Team. We handle 500+ servers daily, from shared hosting to enterprise dedicated infrastructure.

    Wrap-Up

    That’s the whole thing. Install the daemon, load the PHP extension, point LiteSpeed Cache at localhost:11211, and verify the hits are climbing. Four steps, fifteen minutes, and your database stops doing the same work over and over.

    Before you close the ticket, confirm: 1) the service is running, 2) php -m shows memcached, 3) the LSCache drop-in is enabled, 4) get_hits is climbing. All green? Then you’re done. Done.