I use cPanel and Cloulinux and Litespeed
I installed the LSMCD via cPanel plugin file in this command:
sudo git clone https://github.com/litespeedtech/lsmcd.git
sudo cd lsmcd
sudo ./lsmcd_cpanel.sh
LSMCD is working properly with TCP
connection, but when I configured to unix socket
, it shows nothing.
test.php
<?php
$mc = new Memcached();
$mc->setOption(Memcached::OPT_BINARY_PROTOCOL, true);
$mc->setOption(Memcached::OPT_COMPRESSION, false);
$mc->addServer('/tmp/lsmcd/lsmcd.sock', 0);
$mc->setSaslAuthData('testuser', 'testpass');
$mc->set("foo", "bar");
$value = $mc->get('foo');
echo $value;
And it doesn't show anything.
/usr/local/lsmcd/conf/node.conf
Repl.HeartBeatReq=30
Repl.HeartBeatRetry=3000
Repl.MaxTidPacket=2048000
Repl.GzipStream=YES
Repl.LbAddrs=127.0.0.1:12340
Repl.ListenSvrAddr=127.0.0.1:12340
REPL.DispatchAddr=127.0.0.1:5501
RepldSockPath=/tmp/repld.usock
CACHED.PRIADDR=127.0.0.1:11000
#CACHED.ADDR=127.0.0.1:11211
CACHED.ADDR=UDS:///tmp/lsmcd/lsmcd.sock
#default is 8, it can be bigger depending on cache data amount
Cached.Slices=8
Cached.Slice.Priority.0=100
Cached.Slice.Priority.1=100
Cached.Slice.Priority.2=100
Cached.Slice.Priority.3=100
Cached.Slice.Priority.4=100
Cached.Slice.Priority.5=100
Cached.Slice.Priority.6=100
Cached.Slice.Priority.7=100
Cached.ShmDir=/dev/shm/lsmcd
Cached.UseSasl=true
Cached.DataByUser=true
Cached.Anonymous=false
Cached.SaslDB=/etc/sasllsmcd
##this is the global setting, no need to have per slice configuration.
User=nobody
Group=nobody
#depends CPU core
CachedProcCnt=4
CachedSockPath=/tmp/cached.usock.
TmpDir=/tmp/lsmcd
LogLevel=notice
#LogLevel=dbg_medium
LogFile=/tmp/lsmcd.log
But it works when I switch to TCP
:
CACHED.ADDR=127.0.0.1:11211
#CACHED.ADDR=UDS:///tmp/lsmcd/lsmcd.sock
sudo systemctl restart lsmcd
$mc->addServer('127.0.0.1', 11211);
it returns "bar"
In this article: Using Memcached in a UNIX socket, it is mentioned that:
1.Stop Memcached systemctl stop memcached
2. Copy the service file cp /usr/lib/systemd/system/memcached.service /etc/systemd/system/memcached.service
3. Add the following content to /etc/systemd/system/memcached.service. After [Service], please change username to the same user that runs PHP: User=username Group=username The contents of the file should look like this:
But there isn't any memcached
service in the system. Because I installed lscmd
, not memcached.