Proper install for memcached on CloudLinux 8 for ea-php
I could really use some guidance / opinions please.
After a lot of digging / searching around, I'm finding multiple suggestions on how to get memcached running, and although the all seem fairly easy, most are old methods and O/S version specific.
I'm trying to get memcached running proper / usable on newly provisioned servers that are running CloudLinux 8.9.0 (converted from Almalinux 8) and cPanel 118.0.4
Not using CloudLinux PHP selector. Sticking with just cPanel's ea-phpxx versions and MultiPHP manager.
I've installed the following modules / extensions via EasyApache 4:
Apache module mod_socache_memcache version 2.4.58-3.el8.cloudlinux is installed via EasyApache 4
PHP extension php74-php-memcached version 3.1.5-2.el8.cloudlinux is installed via EasyApache 4
PHP extension php81-php-memcached version 3.2.0-1.el8.cloudlinux is installed via EasyApache 4
PHP extension php82-php-memcached version 3.2.0-1.el8.cloudlinux is installed via EasyApache 4
PHP extension php83-php-memcached version 3.2.0-1.el8.cloudlinux is installed via EasyApache 4
And so now it's time to get memcached actually running:
~]# systemctl start memcached
Failed to start memcached.service: Unit memcached.service not found.
And I'm really unsure of the best method give my new O/S / new servers, and the outdated articles I've found.
Is there one specific way memcached should be installed / started / running in CL 8.9.0 / cPanel 118.0.4 / using only ea-phpXX PHP versions?
Thank you for any help please.
-
Thanks for sharing this in such detail!
1 -
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:
0 -
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: 127.0.0.1:11211" 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 https://cloudlinux.zendesk.com/hc/en-us/articles/9718828053020-Unable-to-connect-to-memcached 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:
PORT="11211"
USER="memcached"
MAXCONN="1024"
CACHESIZE="64"
OPTIONS="-l 127.0.0.1,::1"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:
PORT="11211"
USER="memcached"
# MAXCONN="1024"
MAXCONN="2048"
# CACHESIZE="64"
CACHESIZE="4096"
# OPTIONS="-l 127.0.0.1,::1"
OPTIONS="-l 127.0.0.1 -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.
0
Please sign in to leave a comment.
Comments
3 comments