PHP 连接 Memcached 需要先安装 memcache 扩展模块:
cd /usr/local/src wget http://www.apelearn.com/bbs/data/attachment/forum/memcache-2.2.3.tgz tar xf memcache-2.2.3.tgz cd memcache-2.2.3 /usr/local/php/bin/phpize ./configure --with-php-config=/usr/local/php/bin/php-config make && make install echo ‘extension = "memcache.so"‘ >> /usr/local/php/etc/php.ini
[root@localhost ~]# /usr/local/php/bin/php -m | grep memcache memcache
测试 PHP 是否连接 Memcached:
[root@localhost ~]# curl http://www.apelearn.com/study_v2/.memcache.txt > 1.php
[root@localhost ~]# /usr/local/php/bin/php 1.php //看到如下输出则表示连接成功 Get key1 value: This is first value<br>Get key1 value: This is replace value<br>Get key2 value: Array ( [0] => aaa [1] => bbb [2] => ccc [3] => ddd )
原文地址:https://www.cnblogs.com/pzk7788/p/10460424.html
时间: 2024-10-08 18:27:15