======How to use Memcached in a UNIX Socket======
Memcached can run in a UNIX socket, which provides better performance than a TCP connection.
**Note**: If Memcached fails to start, it is usually due to permission and user problems. Please use root privilege to execute the following instructions, and verify that the socket path is writable to the designated user.
=====For Centos7.X=====
- Stop Memcached systemctl stop memcached
- Copy the service file cp /usr/lib/systemd/system/memcached.service /etc/systemd/system/memcached.service
- 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: {{ :litespeed_wiki:cache:lscwp:configuration:object-cache3.jpg?direct |}}
- Edit ''/etc/sysconfig/memcached'', changing the path to your desired location, and the username to the same one used in Step 3: OPTIONS=""
USER="memcached"
becomes OPTIONS="-s /path/to/memcached.sock -a 0770"
USER="username"
- Start Memcached again: systemctl start memcached
- Verify it started successfully: systemctl status memcached
- Check if everything is working well: nc -U /path/to/memcached.sock
stats
=====for Centos6.X=====
- Stop Memcached systemctl stop memcached
- Edit ''/etc/sysconfig/memcached'' and change OPTIONS=""
USER=""
to OPTIONS="-s /path/to/memcached.sock -a 0770"
USER="username"
where ''userid'' is the same user that runs PHP.
- Start Memcached service memcached start
- Check if everything is working well: nc -U /path/to/memcached.sock
stats
=====For Ubuntu 17.10, Ubuntu 16.04, Debian 8 and Debian 9=====
- Stop Memcached systemctl stop memcached
- Edit ''/etc/memcached.conf'', comment out host and port, add socket path and permission -s /path/to/memcached.sock
-a 0770
and change ''-u memcache'' to ''-u username'' where ''username'' is the same user that runs PHP.
- Start Memcached again systemctl start memcached
- Check if everything is working well: nc -U /path/to/memcached.sock
stats
=====for Ubuntu 14.04 and Debian 7=====
- Stop Memcached service memcached stop
- Edit ''/etc/memcached.conf'', comment out host and port, add socket path and permission -s /path/to/memcached.sock
-a 0770
and change ''-u memcache'' to ''-u username'' where ''username'' is the same user that runs PHP.
- Start Memcached again service memcached start
- Check if everything is working well: nc -U /path/to/memcached.sock
stats