[iyunv@node120 ~]# telnet 127.0.0.1 11211
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
stats
STAT pid 24034
STAT uptime 792
STAT time 1451025193
STAT version 1.4.4
STAT pointer_size 64
STAT rusage_user 0.016997
STAT rusage_system 0.043993
STAT curr_connections 10
STAT total_connections 11
STAT connection_structures 11
STAT cmd_get 0
STAT cmd_set 0
STAT cmd_flush 0
STAT get_hits 0
STAT get_misses 0
STAT delete_misses 0
STAT delete_hits 0
STAT incr_misses 0
STAT incr_hits 0
STAT decr_misses 0
STAT decr_hits 0
STAT cas_misses 0
STAT cas_hits 0
STAT cas_badval 0
STAT auth_cmds 0
STAT auth_errors 0
STAT bytes_read 7
STAT bytes_written 0
STAT limit_maxbytes 67108864
STAT accepting_conns 1
STAT listen_disabled_num 0
STAT threads 4
STAT conn_yields 0
STAT bytes 0
set mykey 0 30 11
hello hey1w
STORED
get mykey
VALUE mykey 0 11
hello hey1w
END
set testkey 0 120 1
1
STORED
incr testkey 1
2
incr test 3
NOT_FOUND
incr testkey 3
5
decr testkey 2
3
get testkey
VALUE testkey 0 1
3
END
get mykey
END
[iyunv@node120 memcache-2.2.7]# which php-config
/usr/bin/php-config
[iyunv@node120 memcache-2.2.7]# ./configure --with-php-config=/usr/bin/php-config
[iyunv@node120 memcache-2.2.7]# make && make install
[iyunv@node120 memcache-2.2.7]# ls /usr/lib64/php/modules/
curl.so fileinfo.so json.so memcache.so phar.so zip.so
[iyunv@node120 memcache-2.2.7]# vim /etc/php.ini
918 ; syntax:
919 ;
920 ; extension=modulename.extension
921 extension=memcache.so
922
923 ; For example
[iyunv@node120 memcache-2.2.7]# service httpd restart
停止 httpd: [失败]
正在启动 httpd:httpd: apr_sockaddr_info_get() failed for node120.zye.com
httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
[确定
[iyunv@node120 memcache-2.2.7]# vim /var/www/html/index.php
<?php
phpinfo ();
?>
添加test.php
[iyunv@node120 memcache-2.2.7]# vim /var/www/html/test.php
1 <?php
2 $mem = new Memcache;
3 $mem->connect("127.0.0.1", 11211) or die("Could not conn ect");
4
5 $version = $mem->getVersion();
6 echo "Server's version: ".$version."<br/>\n";
7
8 $mem->set('hellokey', 'Hello World', 0, 600) or die("Fail ed to save data at the memcached server");
9 echo "Store data in the cache (data will expire in 600 se conds)<br/>\n";
10
11 $get_result = $mem->get('hellokey');
12 echo "$get_result is from memcached server.";
13 ?>
[iyunv@node120 memcache-2.2.7]# telnet 127.0.0.1 11211
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
get hellokey
VALUE hellokey 0 11
Hello World
END
quit
[iyunv@node120 memcache-2.2.7]# vim /etc/httpd/conf.d/phpMemcachedAdmin.conf
1 # phpMemcachedAdmin - Graphic stand-alone administration for memcached to monitor and debug purpose
2 #
3 # Allows only localhost by default
4
5 Alias /phpMemcachedAdmin /usr/share/phpMemcachedAdmin
6 Alias /phpmemcachedadmin /usr/share/phpMemcachedAdmin
7
8 <Directory /usr/share/phpMemcachedAdmin/>
9 <IfModule mod_authz_core.c>
10 # Apache 2.4
11 <RequireAny>
12 Require local
13 </RequireAny>
14 </IfModule>
15 <IfModule !mod_authz_core.c>
16 # Apache 2.2
17 Order Deny,Allow
18 Allow from All
19 </IfModule>
20 </Directory>
[iyunv@node120 memcache-2.2.7]# service httpd restart
停止 httpd: [确定]
正在启动 httpd:httpd: Could not reliably determine the server's fully qualified domain name, using node120.zye.com for ServerName
[确定