Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
memcached_unix_socket [2018/01/17 22:21]
qtwrk [How to use memcached in UNIX socket?]
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 UNIX socket?​====== +~~REDIRECT>​https://​docs.litespeedtech.com/products/lsmcd/configuration/general/~~
- +
-Memcached can also run in UNIX socket which provides better performance than TCP connection. +
- +
- +
-Please use root privilege to the following instructions. +
- +
-If memcached failed to start , it is usually due to permission and user problem , please check the socket path is writable to designated user.  +
-=====for Centos7.X===== +
- +
-1. Stop memcached <code>systemctl stop memcached</​code>​ +
- +
-2. Copy file service file <​code>​cp /​usr/​lib/​systemd/​system/​memcached.service /​etc/​systemd/​system/​memcached.service</​code>​ +
- +
-3. Add following content to /​etc/​systemd/​system/​memcached.service ,after [Service], please change username to php user +
-<​code>​User=username +
-Group=username +
-</​code>​ +
- +
-the file should be like this: +
-{{ :​litespeed_wiki:​cache:​lscwp:​configuration:​object-cache3.jpg?​direct |}} +
- +
-4. Edit /​etc/​sysconfig/​memcached , please change path to your desired location. +
-change from <​code>​OPTIONS=""</​code>​ to <​code>​OPTIONS="​-s /​path/​to/​memcached.sock -a 0770"</​code>​ +
-and change username to the same user name in step 3. +
-change from <​code>​USER="​memcached"</​code>​ to <​code>​USER="​username"</​code>​ +
- +
-5. Now start memcached again<​code>​systemctl start memcached</​code>​ +
- +
-6. Check if it started successfully , +
-<​code>​systemctl status memcached</​code>​ +
- +
-7. Check if everything goes well. +
-<​code>​nc -U /​path/​to/​memcached.sock</​code>​ +
-and then type <​code>​stats</​code>​ +
- +
- +
-=====for Centos6.X===== +
- +
-1. Stop memcached <​code>​service memcached stop</​code>​ +
- +
-2. Edit /​etc/​sysconfig/​memcached +
-change <​code>​OPTIONS=""</​code>​ to <​code>​OPTIONS="​-s /​path/​to/​memcached.sock -a 0770"</​code>​ +
-change <​code>​USER=""</​code>​ to <​code>​USER="​username"</​code>​ the same user runs php +
- +
-3. Start memcached <​code>​service memcached start</​code>​ +
- +
-4. Check if everything goes well. +
-<​code>​nc -U /​path/​to/​memcached.sock</​code>​ +
-and then type <​code>​stats</​code>​ +
-=====for Ubuntu 17.10, Ubuntu 16.04, Debian 8 and Debian 9===== +
- +
-1. Stop memcached <​code>​systemctl stop memcached</​code>​ +
- +
-2. Edit <​code>/​etc/​memcached.conf</​code>​comment out host and port , add socket path and permission. +
-<​code>​-s /​path/​to/​memcached.sock +
--a 0770</​code>​ +
-and change <​code>​-u </​code>​ to <​code>​-u username</​code>​ +
-a username that runs PHP. +
- +
- +
- +
-3. Start memcached again <​code>​systemctl start memcached</​code>​ +
- +
-4. Check if everything goes well. +
-<​code>​nc -U /​path/​to/​memcached.sock</​code>​ +
-and then type <​code>​stats</​code>​ +
- +
- +
-=====for Ubuntu 14.04 and Debian 7===== +
- +
-1. Stop memcached <​code>​service memcached stop</​code>​ +
- +
-2. Edit <​code>/​etc/​memcached.conf</​code>​comment out host and port , add socket path and permission. +
-<​code>​-s /​tmp/​memcached.sock +
--a 755</​code>​ +
-Add additional line on Ubuntu 14.04 +
-<​code>​-u root</​code>​ +
- +
-{{ :​litespeed_wiki:​cache:​lscwp:​configuration:​mem-socket-ubuntu1.png?​direct |}} +
- +
-3. Start memcached again <​code>​service memcached start</​code>​ +
- +
-4. Check if everything goes well. +
-<​code>​nc -U /​tmp/​memcached.sock</​code>​ +
-and then type <​code>​stats</​code>​ +
- +
- +
- +
- +
- +
- +
- +
- +
- +
- +
- +
- +
- +
- +
- +
- +
- +
- +
- +
- +
- +
- +
- +
-sources: +
- +
-https://www.orangecoat.com/how-to/run-memcached-as-a-socket-under-systemd-in-centos-or-rhel-7 +
- +
-https://chirale.org/​2015/​09/​04/​installing-and-configure-memcache-on-centos-7/​ +
- +
-https://​guides.wp-bullet.com/​install-latest-memcached-object-cache-wordpress-php5-debian/+
  • Admin
  • Last modified: 2018/01/17 22:21
  • by qtwrk