Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision | |||
memcached_unix_socket [2018/01/18 16:29] Lisa Clarke removed |
memcached_unix_socket [2025/06/03 18:05] (current) Lisa Clarke Redirect to new Documentation Site |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ======How to use Memcached in a UNIX Socket====== | + | ~~REDIRECT>https://docs.litespeedtech.com/products/lsmcd/configuration/general/~~ |
- | + | ||
- | 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 <code>systemctl stop memcached</code> | + | |
- | - Copy the service file <code>cp /usr/lib/systemd/system/memcached.service /etc/systemd/system/memcached.service</code> | + | |
- | - Add the following content to ''/etc/systemd/system/memcached.service''. After ''[Service]'', please change username to the same user that runs PHP: <code>User=username | + | |
- | Group=username | + | |
- | </code> 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: <code>OPTIONS="" | + | |
- | USER="memcached"</code> becomes <code>OPTIONS="-s /path/to/memcached.sock -a 0770" | + | |
- | USER="username"</code> | + | |
- | - Start Memcached again: <code>systemctl start memcached</code> | + | |
- | - Verify it started successfully: <code>systemctl status memcached</code> | + | |
- | - Check if everything is working well: <code>nc -U /path/to/memcached.sock | + | |
- | stats</code> | + | |
- | + | ||
- | =====for Centos6.X===== | + | |
- | + | ||
- | - Stop Memcached <code>systemctl stop memcached</code> | + | |
- | - Edit ''/etc/sysconfig/memcached'' and change <code>OPTIONS="" | + | |
- | USER=""</code> to <code>OPTIONS="-s /path/to/memcached.sock -a 0770" | + | |
- | USER="username"</code> where ''userid'' is the same user that runs PHP. | + | |
- | - Start Memcached <code>service memcached start</code> | + | |
- | - Check if everything is working well: <code>nc -U /path/to/memcached.sock | + | |
- | stats</code> | + | |
- | + | ||
- | =====For Ubuntu 17.10, Ubuntu 16.04, Debian 8 and Debian 9===== | + | |
- | + | ||
- | - Stop Memcached <code>systemctl stop memcached</code> | + | |
- | - Edit ''/etc/memcached.conf'', comment out host and port, add socket path and permission <code>-s /path/to/memcached.sock | + | |
- | -a 0770</code> and change ''-u memcache'' to ''-u username'' where ''username'' is the same user that runs PHP. | + | |
- | - Start Memcached again <code>systemctl start memcached</code> | + | |
- | - Check if everything is working well: <code>nc -U /path/to/memcached.sock | + | |
- | stats</code> | + | |
- | + | ||
- | =====for Ubuntu 14.04 and Debian 7===== | + | |
- | + | ||
- | - Stop Memcached <code>service memcached stop</code> | + | |
- | - Edit ''/etc/memcached.conf'', comment out host and port, add socket path and permission <code>-s /path/to/memcached.sock | + | |
- | -a 0770</code> and change ''-u memcache'' to ''-u username'' where ''username'' is the same user that runs PHP. | + | |
- | - Start Memcached again <code>service memcached start</code> | + | |
- | - Check if everything is working well: <code>nc -U /path/to/memcached.sock | + | |
- | stats</code> | + |