21.5 memcached命令行
Memcached語法規則:
1. <command name> <key> <flags> <exptime> <bytes>\r\n <data block>\r\n
注:\r\n在windows下是Enter鍵
2. <command name> 可以是set, add, replace
3. set表示按照相應的<key>存儲該數據,沒有的時候增加,有的時候覆蓋
4. add表示按照相應的<key>添加該數據,但是如果該<key>已經存在則會操作失敗
5. replace表示按照相應的<key>替換數據,但是如果該<key>不存在則操作失敗。
6. <key> 客戶端需要保存數據的key
7. <flags> 是一個16位的無符號的整數(以十進制的方式表示)。該標誌將和需要存儲的數據一起存儲,並在客戶端get數據時返回。客戶端可以將此標誌用做特殊用途,此標誌對服務器來說是不透明的。
8. <exptime> 爲過期的時間。若爲0表示存儲的數據永遠不過期(但可被服務器算法:LRU 等替換)。如果非0(unix時間或者距離此時的秒數),當過期後,服務器可以保證用戶得不到該數據(以服務器時間爲標準)。
9. <bytes> 需要存儲的字節數,當用戶希望存儲空數據時<bytes>可以爲0
10. <data block>需要存儲的內容,輸入完成後,最後客戶端需要加上\r\n(直接點擊Enter)作爲結束標誌。
啓動:
[root@aminglinux-149 ~]# systemctl start memcached
1. 安裝telnet
[root@aminglinux-149 ~]# yum install -y telnet 已加載插件:fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * epel: mirrors.aliyun.com * extras: mirrors.neusoft.edu.cn * updates: mirrors.neusoft.edu.cn 軟件包 1:telnet-0.17-64.el7.x86_64 已安裝並且是最新版本 無須任何處理
2. 用telnet 指定ip 端口,進入telnet界面:
[root@aminglinux-149 ~]# telnet 127.0.0.1 11211 Trying 127.0.0.1... Connected to 127.0.0.1. Escape character is '^]'. set key1 0 30 5 12345
查看key1存儲的內容(查看超出了存儲時間,會查不到的):
get key1 END
提示:在telnet模式下,退格鍵需要按住Ctrl鍵
實驗案例:
設定key1:flags爲1 120秒到期時間 4個存儲字節
set key1 1 120 4 1234 STORED
替換key1:flags爲1 0爲不限制時間 6個存儲字節
replace key1 1 0 6 123456 NOT_STORED
查看key1的值:
get key1 END
刪除key1的值:
delete key1 NOT_FOUND
21.6 memcached數據導出和導入
1. 導出memcached的數據:
[root@aminglinux-149 ~]# memcached-tool 127.0.0.1:11211 dump Dumping memcache contents Number of buckets: 0 Number of items :
2. 把 導出memcached的數據,重定向到指定文件data.txt內:
[root@aminglinux-149 ~]# memcached-tool 127.0.0.1:11211 dump > data.txt
3. 重啓memcached:
(清理之前存儲的數據,爲了導入已存在的數據會不被覆蓋的)
[root@aminglinux-149 ~]# systemctl restart memcached
4. data.txt導入到memcached:
[root@aminglinux-149 ~]# nc 127.0.01 11211 < data.txt
若nc命令不存在,yum install nc
注意:導出的數據是帶有一個時間戳的,這個時間戳就是該條數據過期的時間點,如果當前時間已經超過該時間戳,那麼是導入不進去的
21.7 php連接memcached
1. 進入/...src/目錄下,下載memcache包:
[root@aminglinux-149 ~]# cd /usr/local/src/ [root@aminglinux-149 src]# wget http://×××w.apelearn.com/bbs/data/attachment/forum/memcache-2.2.3.tgz --2018-11-24 17:48:01-- http://×××w.apelearn.com/bbs/data/attachment/forum/memcache-2.2.3.tgz 正在解析主機 ×××w.apelearn.com (×××w.apelearn.com)... 47.104.7.242 正在連接 ×××w.apelearn.com (×××w.apelearn.com)|47.104.7.242|:80... 已連接。 已發出 HTTP 請求,正在等待迴應... 200 OK 長度:27366 (27K) [application/octet-stream] 正在保存至: “memcache-2.2.3.tgz” 100%[==============================================>] 27,366 --.-K/s 用時 0.06s 2018-11-24 17:48:02 (462 KB/s) - 已保存 “memcache-2.2.3.tgz” [27366/27366]) [root@aminglinux-149 src]# tar zxvf memcache-2.2.3.tgz package.xml memcache-2.2.3/config.m4 memcache-2.2.3/config9.m4 memcache-2.2.3/config.w32 memcache-2.2.3/CREDITS memcache-2.2.3/example.php memcache-2.2.3/memcache.c memcache-2.2.3/memcache_queue.c memcache-2.2.3/memcache_session.c memcache-2.2.3/memcache_standard_hash.c memcache-2.2.3/memcache_consistent_hash.c memcache-2.2.3/memcache.dsp memcache-2.2.3/php_memcache.h memcache-2.2.3/memcache_queue.h memcache-2.2.3/README [root@aminglinux-149 src]# cd memcache-2.2.3 [root@aminglinux-149 memcache-2.2.3]# yum install -y autoconf 已加載插件:fastestmirror, langpacks Loading mirror speeds from cached hostfile epel/x86_64/metalink | 3.5 kB 00:00:00 * base: mirrors.aliyun.com * epel: ftp.yz.yamagata-u.ac.jp * extras: mirrors.neusoft.edu.cn * updates: mirrors.neusoft.edu.cn base | 3.6 kB 00:00:00 epel | 3.2 kB 00:00:00 extras [root@aminglinux-149 memcache-2.2.3]# /usr/local/php-fpm/bin/phpize Configuring for: PHP Api Version: 20131106 Zend Module Api No: 20131226 Zend Extension Api No: 220131226 [root@aminglinux-149 memcache-2.2.3]# ./configure --with-php-config=/usr/local/php-fpm/bin/php-config checking for grep that handles long lines and -e... /usr/bin/grep checking for egrep... /usr/bin/grep -E checking for a sed that does not truncate output... /usr/bin/sed checking for cc... cc checking for C compiler default output file name... a.out checking whether the C compiler works... yes checking whether we are cross compiling... no checking for suffix of executables... checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether cc accepts -g... yes checking for cc option to accept ISO C89... none needed checking how to run the C preprocessor... cc -E checking for icc... no checking for suncc... no checking whether cc understands -c and -o together... yes checking for system library directory... lib checking if compiler supports -R... no checking if compiler supports -Wl,-rpath,... yes checking build system type... x86_64-unknown-linux-gnu checking host system type... x86_64-unknown-linux-gnu checking target system type... x86_64-unknown-linux-gnu checking for PHP prefix... /usr/local/php-fpm checking for PHP includes... -I/usr/local/php-fpm/include/php -I/usr/local/php-fpm/include/php/main -I/usr/local/php-fpm/include/php/TSRM -I/usr/local/php-fpm/include/php/Zend -I/usr/local/php-fpm/include/php/ext -I/usr/local/php-fpm/include/php/ext/date/lib checking for PHP extension directory... /usr/local/php-fpm/lib/php/extensions/no-debug-non-zts-20131226 checking for PHP installed headers prefix... /usr/local/php-fpm/include/php checking if debug is enabled... no checking if zts is enabled... no checking for re2c... no configure: WARNING: You will need re2c 0.13.4 or later if you want to regenerate PHP parsers. checking for gawk... gawk checking whether to enable memcache support... yes, shared checking whether to enable memcache session handler support... yes checking for the location of ZLIB... no checking for the location of zlib... /usr checking for session includes... /usr/local/php-fpm/include/php checking for memcache session support... enabled checking for ld used by cc... /usr/bin/ld checking if the linker (/usr/bin/ld) is GNU ld... yes checking for /usr/bin/ld option to reload object files... -r checking for BSD-compatible nm... /usr/bin/nm -B checking whether ln -s works... yes checking how to recognize dependent libraries... pass_all checking for ANSI C header files... yes checking for sys/types.h... yes checking for sys/stat.h... yes checking for stdlib.h... yes checking for string.h... yes checking for memory.h... yes checking for strings.h... yes checking for inttypes.h... yes checking for stdint.h... yes checking for unistd.h... yes checking dlfcn.h usability... yes checking dlfcn.h presence... yes checking for dlfcn.h... yes checking the maximum length of command line arguments... 1572864 checking command to parse /usr/bin/nm -B output from cc object... ok checking for objdir... .libs checking for ar... ar checking for ranlib... ranlib checking for strip... strip checking if cc supports -fno-rtti -fno-exceptions... no checking for cc option to produce PIC... -fPIC checking if cc PIC flag -fPIC works... yes checking if cc static flag -static works... no checking if cc supports -c -o file.o... yes checking whether the cc linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes checking whether -lc should be explicitly linked in... no checking dynamic linker characteristics... GNU/Linux ld.so checking how to hardcode library paths into programs... immediate checking whether stripping libraries is possible... yes checking if libtool supports shared libraries... yes checking whether to build shared libraries... yes checking whether to build static libraries... no creating libtool appending configuration tag "CXX" to libtool configure: creating ./config.status config.status: creating config.h [root@aminglinux-149 memcache-2.2.3]# echo $? 0 [root@aminglinux-149 memcache-2.2.3]# make && make install /bin/sh /usr/local/src/memcache-2.2.3/libtool --mode=compile cc -I/usr/local/php-fpm/include/php -I. -I/usr/local/src/memcache-2.2.3 -DPHP_ATOM_INC -I/usr/local/src/memcache-2.2.3/include -I/usr/local/src/memcache-2.2.3/main -I/usr/local/src/memcache-2.2.3 -I/usr/local/php-fpm/include/php -I/usr/local/php-fpm/include/php/main -I/usr/local/php-fpm/include/php/TSRM -I/usr/local/php-fpm/include/php/Zend -I/usr/local/php-fpm/include/php/ext -I/usr/local/php-fpm/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /usr/local/src/memcache-2.2.3/memcache.c -o memcache.lo mkdir .libs cc -I/usr/local/php-fpm/include/php -I. -I/usr/local/src/memcache-2.2.3 -DPHP_ATOM_INC -I/usr/local/src/memcache-2.2.3/include -I/usr/local/src/memcache-2.2.3/main -I/usr/local/src/memcache-2.2.3 -I/usr/local/php-fpm/include/php -I/usr/local/php-fpm/include/php/main -I/usr/local/php-fpm/include/php/TSRM -I/usr/local/php-fpm/include/php/Zend -I/usr/local/php-fpm/include/php/ext -I/usr/local/php-fpm/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /usr/local/src/memcache-2.2.3/memcache.c -fPIC -DPIC -o .libs/memcache.o /usr/local/src/memcache-2.2.3/memcache.c: 在函數‘mmc_str_left’中: /usr/local/src/memcache-2.2.3/memcache.c:1116:8: 警告:assignment discards ‘const’ qualifier from pointer target type [默認啓用] found = php_memnstr(haystack, needle, needle_len, haystack + haystack_len); ^ /usr/local/src/memcache-2.2.3/memcache.c: 在函數‘mmc_stats_parse_stat’中: /usr/local/src/memcache-2.2.3/memcache.c:1523:13: 警告:assignment discards ‘const’ qualifier from pointer target type [默認啓用] if ((space = php_memnstr(start, " ", 1, end)) == NULL) { ^ /usr/local/src/memcache-2.2.3/memcache.c:1528:13: 警告:assignment discards ‘const’ qualifier from pointer target type [默認啓用] if ((colon = php_memnstr(start, ":", 1, space - 1)) != NULL) { ^ /usr/local/src/memcache-2.2.3/memcache.c: 在函數‘mmc_stats_parse_item’中: /usr/local/src/memcache-2.2.3/memcache.c:1566:13: 警告:assignment discards ‘const’ qualifier from pointer target type [默認啓用] if ((space = php_memnstr(start, " ", 1, end)) == NULL) { ^ /usr/local/src/memcache-2.2.3/memcache.c:1574:13: 警告:assignment discards ‘const’ qualifier from pointer target type [默認啓用] for (value = php_memnstr(space, "[", 1, end); value != NULL && value <= end; value = php_memnstr(value + 1, ";", 1, end)) { ^ /usr/local/src/memcache-2.2.3/memcache.c:1574:85: 警告:assignment discards ‘const’ qualifier from pointer target type [默認啓用] for (value = php_memnstr(space, "[", 1, end); value != NULL && value <= end; value = php_memnstr(value + 1, ";", 1, end)) { ^ /usr/local/src/memcache-2.2.3/memcache.c:1579:34: 警告:assignment discards ‘const’ qualifier from pointer target type [默認啓用] if (value <= end && (value_end = php_memnstr(value, " ", 1, end)) != NULL && value_end <= end) { ^ /usr/local/src/memcache-2.2.3/memcache.c: 在函數‘mmc_stats_parse_generic’中: /usr/local/src/memcache-2.2.3/memcache.c:1603:14: 警告:assignment discards ‘const’ qualifier from pointer target type [默認啓用] if ((space = php_memnstr(start, " ", 1, end)) != NULL) { ^ /bin/sh /usr/local/src/memcache-2.2.3/libtool --mode=compile cc -I/usr/local/php-fpm/include/php -I. -I/usr/local/src/memcache-2.2.3 -DPHP_ATOM_INC -I/usr/local/src/memcache-2.2.3/include -I/usr/local/src/memcache-2.2.3/main -I/usr/local/src/memcache-2.2.3 -I/usr/local/php-fpm/include/php -I/usr/local/php-fpm/include/php/main -I/usr/local/php-fpm/include/php/TSRM -I/usr/local/php-fpm/include/php/Zend -I/usr/local/php-fpm/include/php/ext -I/usr/local/php-fpm/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /usr/local/src/memcache-2.2.3/memcache_queue.c -o memcache_queue.lo cc -I/usr/local/php-fpm/include/php -I. -I/usr/local/src/memcache-2.2.3 -DPHP_ATOM_INC -I/usr/local/src/memcache-2.2.3/include -I/usr/local/src/memcache-2.2.3/main -I/usr/local/src/memcache-2.2.3 -I/usr/local/php-fpm/include/php -I/usr/local/php-fpm/include/php/main -I/usr/local/php-fpm/include/php/TSRM -I/usr/local/php-fpm/include/php/Zend -I/usr/local/php-fpm/include/php/ext -I/usr/local/php-fpm/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /usr/local/src/memcache-2.2.3/memcache_queue.c -fPIC -DPIC -o .libs/memcache_queue.o /bin/sh /usr/local/src/memcache-2.2.3/libtool --mode=compile cc -I/usr/local/php-fpm/include/php -I. -I/usr/local/src/memcache-2.2.3 -DPHP_ATOM_INC -I/usr/local/src/memcache-2.2.3/include -I/usr/local/src/memcache-2.2.3/main -I/usr/local/src/memcache-2.2.3 -I/usr/local/php-fpm/include/php -I/usr/local/php-fpm/include/php/main -I/usr/local/php-fpm/include/php/TSRM -I/usr/local/php-fpm/include/php/Zend -I/usr/local/php-fpm/include/php/ext -I/usr/local/php-fpm/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /usr/local/src/memcache-2.2.3/memcache_standard_hash.c -o memcache_standard_hash.lo cc -I/usr/local/php-fpm/include/php -I. -I/usr/local/src/memcache-2.2.3 -DPHP_ATOM_INC -I/usr/local/src/memcache-2.2.3/include -I/usr/local/src/memcache-2.2.3/main -I/usr/local/src/memcache-2.2.3 -I/usr/local/php-fpm/include/php -I/usr/local/php-fpm/include/php/main -I/usr/local/php-fpm/include/php/TSRM -I/usr/local/php-fpm/include/php/Zend -I/usr/local/php-fpm/include/php/ext -I/usr/local/php-fpm/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /usr/local/src/memcache-2.2.3/memcache_standard_hash.c -fPIC -DPIC -o .libs/memcache_standard_hash.o /bin/sh /usr/local/src/memcache-2.2.3/libtool --mode=compile cc -I/usr/local/php-fpm/include/php -I. -I/usr/local/src/memcache-2.2.3 -DPHP_ATOM_INC -I/usr/local/src/memcache-2.2.3/include -I/usr/local/src/memcache-2.2.3/main -I/usr/local/src/memcache-2.2.3 -I/usr/local/php-fpm/include/php -I/usr/local/php-fpm/include/php/main -I/usr/local/php-fpm/include/php/TSRM -I/usr/local/php-fpm/include/php/Zend -I/usr/local/php-fpm/include/php/ext -I/usr/local/php-fpm/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /usr/local/src/memcache-2.2.3/memcache_consistent_hash.c -o memcache_consistent_hash.lo cc -I/usr/local/php-fpm/include/php -I. -I/usr/local/src/memcache-2.2.3 -DPHP_ATOM_INC -I/usr/local/src/memcache-2.2.3/include -I/usr/local/src/memcache-2.2.3/main -I/usr/local/src/memcache-2.2.3 -I/usr/local/php-fpm/include/php -I/usr/local/php-fpm/include/php/main -I/usr/local/php-fpm/include/php/TSRM -I/usr/local/php-fpm/include/php/Zend -I/usr/local/php-fpm/include/php/ext -I/usr/local/php-fpm/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /usr/local/src/memcache-2.2.3/memcache_consistent_hash.c -fPIC -DPIC -o .libs/memcache_consistent_hash.o /bin/sh /usr/local/src/memcache-2.2.3/libtool --mode=compile cc -I/usr/local/php-fpm/include/php -I. -I/usr/local/src/memcache-2.2.3 -DPHP_ATOM_INC -I/usr/local/src/memcache-2.2.3/include -I/usr/local/src/memcache-2.2.3/main -I/usr/local/src/memcache-2.2.3 -I/usr/local/php-fpm/include/php -I/usr/local/php-fpm/include/php/main -I/usr/local/php-fpm/include/php/TSRM -I/usr/local/php-fpm/include/php/Zend -I/usr/local/php-fpm/include/php/ext -I/usr/local/php-fpm/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /usr/local/src/memcache-2.2.3/memcache_session.c -o memcache_session.lo cc -I/usr/local/php-fpm/include/php -I. -I/usr/local/src/memcache-2.2.3 -DPHP_ATOM_INC -I/usr/local/src/memcache-2.2.3/include -I/usr/local/src/memcache-2.2.3/main -I/usr/local/src/memcache-2.2.3 -I/usr/local/php-fpm/include/php -I/usr/local/php-fpm/include/php/main -I/usr/local/php-fpm/include/php/TSRM -I/usr/local/php-fpm/include/php/Zend -I/usr/local/php-fpm/include/php/ext -I/usr/local/php-fpm/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /usr/local/src/memcache-2.2.3/memcache_session.c -fPIC -DPIC -o .libs/memcache_session.o /bin/sh /usr/local/src/memcache-2.2.3/libtool --mode=link cc -DPHP_ATOM_INC -I/usr/local/src/memcache-2.2.3/include -I/usr/local/src/memcache-2.2.3/main -I/usr/local/src/memcache-2.2.3 -I/usr/local/php-fpm/include/php -I/usr/local/php-fpm/include/php/main -I/usr/local/php-fpm/include/php/TSRM -I/usr/local/php-fpm/include/php/Zend -I/usr/local/php-fpm/include/php/ext -I/usr/local/php-fpm/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -o memcache.la -export-dynamic -avoid-version -prefer-pic -module -rpath /usr/local/src/memcache-2.2.3/modules memcache.lo memcache_queue.lo memcache_standard_hash.lo memcache_consistent_hash.lo memcache_session.lo cc -shared .libs/memcache.o .libs/memcache_queue.o .libs/memcache_standard_hash.o .libs/memcache_consistent_hash.o .libs/memcache_session.o -Wl,-soname -Wl,memcache.so -o .libs/memcache.so creating memcache.la (cd .libs && rm -f memcache.la && ln -s ../memcache.la memcache.la) /bin/sh /usr/local/src/memcache-2.2.3/libtool --mode=install cp ./memcache.la /usr/local/src/memcache-2.2.3/modules cp ./.libs/memcache.so /usr/local/src/memcache-2.2.3/modules/memcache.so cp ./.libs/memcache.lai /usr/local/src/memcache-2.2.3/modules/memcache.la PATH="$PATH:/sbin" ldconfig -n /usr/local/src/memcache-2.2.3/modules ---------------------------------------------------------------------- Libraries have been installed in: /usr/local/src/memcache-2.2.3/modules If you ever happen to want to link against installed libraries in a given directory, LIBDIR, you must either use libtool, and specify the full pathname of the library, or use the `-LLIBDIR' flag during linking and do at least one of the following: - add LIBDIR to the `LD_LIBRARY_PATH' environment variable during execution - add LIBDIR to the `LD_RUN_PATH' environment variable during linking - use the `-Wl,--rpath -Wl,LIBDIR' linker flag - have your system administrator add LIBDIR to `/etc/ld.so.conf' See any operating system documentation about shared libraries for more information, such as the ld(1) and ld.so(8) manual pages. ---------------------------------------------------------------------- Build complete. Don't forget to run 'make test'. Installing shared extensions: /usr/local/php-fpm/lib/php/extensions/no-debug-non-zts-20131226/ [root@aminglinux-149 memcache-2.2.3]# echo $? 0
6. make install 生成如下文件:
[root@aminglinux-149 memcache-2.2.3]# ls /usr/local/php-fpm/lib/php/extensions/no-debug-non-zts-20131226/ memcache.so mongodb.so opcache.a opcache.so redis.so
7. 編輯php-ini:
[root@aminglinux-149 memcache-2.2.3]# vim /usr/local/php-fpm/etc/php-ini
8. 檢查有沒有memcache這個模塊:
[root@aminglinux-149 memcache-2.2.3]# /usr/local/php-fpm/bin/php -m [PHP Modules] Core ctype curl date dom ereg exif fileinfo filter ftp gd hash iconv json libxml mbstring mcrypt memcache
21.8 memcached中存儲session
1. 下載session存儲腳本:
[root@aminglinux-149 ~]# wget
2. 進入
[root@aminglinux-149 ~]# cd /data/wwwroot/
3. 移動session存儲腳本,並重命名爲php格式腳本:
[root@aminglinux-149 test]# mv /root/.mem_se.txt 1.php
4. curl訪問1.php:
[root@aminglinux-149 test]# curl localhost/1.php
5. 查看tmp下有沒有sess_格式的文件:
test]# ls -lt /tmp/ 總用量 0 srwxrwxrwx 1 mysql mysql 0 11月 25 15:36 mysql.sock srwx------ 1 mongod mongod 0 11月 25 15:36 mongodb-27017.sock srw-rw-rw- 1 root root 0 11月 25 15:36 php-fcgi.sock drwx------ 3 root root 60 11月 25 15:36 systemd-private-7e4b158a75c2468ea9d7a6d8a18ebd8e-httpd.service-Kc3wzD drwx------ 3 root root 60 11月 25 15:36 systemd-private-7e4b158a75c2468ea9d7a6d8a18ebd8e-cups.service-cQ0pZh drwx------ 2 root root 40 11月 25 15:36 vmware-root drwx------ 3 root root 60 11月 25 15:36 systemd-private-7e4b158a75c2468ea9d7a6d8a18ebd8e-chronyd.service-r2RXLD
6. 編輯php-ini:
vim /usr/local/php-fpm/etc/php-ini
註釋掉這行:;session.save_handler = files
添加:
session.save_handler = memcache session.save_path
"tcp://192.168.0.9:11211"
本實例是在lamp/lnmp環境下實現(下面哪種沒問題,就用哪種)
1. 編輯php.ini添加兩行
session.save_handler = memcache session.save_path
"tcp://192.168.0.9:11211"
2. 或者httpd.conf中對應的虛擬主機中添加
php_value session.save_handler "memcache" php_value session.save_path "tcp://192.168.0.9:11211"
3. 或者php-fpm.conf對應的pool中添加
php_value[session.save_handler] = memcache
php_value[session.save_path] = " tcp://192.168.0.9:11211 "
7. curl訪問1.php:
[root@hao-01 test.com]# curl localhost/1.php