Skip to main content

Proper install for memcached on CloudLinux 8 for ea-php



  • cPRex Jurassic Moderator

    Hey there!  There's a bit of a difference between the PHP memcached and memcached running as a daemon.  For example, when you ran that systemctl start command, which version of memcached would it turn on?

    Details on how to setup the daemon for specific accounts can be found here:

  • Metro2

    Thank you cPRex .  I forgot to update this a while back. Actually had a long response / explanation typed up one day and I think my session timed-out / lost my response, and I probably thought "I'll come back to it".

    So the slightly shorter version but still a bit long:

    The solution you pointed to wasn't quite what I was looking for. I needed to have memcached running on more of global level on my new servers like it is on my older servers, so that it's available to all who use things like W3 Total Cache plugin for their WP sites, and even a few forum sites, without having to request individual user account changes.

    What I needed to do is set it up on my new servers like it is on my soon-to-be-old servers so that anyone using a plugin that requires memcached to be running (and also secured away from UDP) would not encounter the dreaded "The following memcached servers are not responding or not running: Object Cache:" and so that plugins like W3TC would not starting filling up /wp-content/cache/objects/ with tons of files etc.... and using up their iNodes.

    It had been so long since I'd originally done the memcached setup on my old servers that I'd forgotten exactly how I did it. But after reading through a variety of threads and articles around the web I was reminded. Even little hints like actually helped.

    Yes, I knew there is a difference between the memcached PHP extensions and the actual memcached daemon. Enabling the the PHP extension for each version of PHP in EasyApache is, well... the easy part.

    The part that I was worried about / unsure about, due to the variety of methods / docs / discussions, was getting memcached daemon running server-wide for all accounts on my shared-hosting service, which was/is doing fine on my older CL6 / cPanel 110 servers but was not prepped on the new CL8 / cPanel 118 boxes that I'm trying to migrate everything to.

    Fortunately as it turns out, doing this was basically the same (in my case) as I had done for the old servers years ago. 

    For me it went something like this for my setup:

    (disclaimer - while this might be helpful to some, it might not be the right choice for others and again, even though I'm not using CloudLinux's PHP Selector and I'm just using cPanel's MultiPHP / ea-php , this is still what works for me)

    1. Via EasyApache 4 ,  add and compile the PHP extension to each PHP version you're running (e.g.  phpXX-php-memcached for php-memcached extension for ea-phpXX)

    2. SSH in as root and run "yum install memcached" and install the package.

    3. Edit /etc/sysconfig/memcached and set the options. For some people the defaults will need to be changed and typically look like this:


    Those defaults might work fine for some people, but I definitely want to disable UDP / protect against remote access risks, and I did mine like this:

    # MAXCONN="1024"
    # CACHESIZE="64"
    # OPTIONS="-l,::1"
    OPTIONS="-l -U 0"

    I commented-out the defaults and left them there (just in case of problems and for reference), and obviously raised some resource values, but more importantly changed the OPTIONS line to prevent UDP / remote access.

    4. Ran "systemctl enable memcached" to enable it.

    I could then use "systemctl status memcached" to see that it was running.

    And ultimately, the combination of installing the modules and extensions as in my original post, combined with the simplified steps I just posted, I was able to get memcached running / available to all users, and things like WordPress cache plugins and forums with built-in caching options are all able to work as they should.

    I can't say whether this is recommended for everyone, but it certainly was the solution for my situation, and hopefully this thread helps someone someday.

  • cPRex Jurassic Moderator

    Thanks for sharing this in such detail!


Please sign in to leave a comment.