您好,登錄后才能下訂單哦!
1、安裝libmemcached庫(kù)
yum install libmemcached
2、下載并解壓memcache文件
wget http://pecl.php.net/get/memcache-3.0.8.tgz
tar xzvf memcache-3.0.8.tgz
cd memcache-3.0.8
3、執(zhí)行phpize擴(kuò)展安裝程序,假設(shè)phpzie的路徑為/usr/local/php/bin/phpize,具體的路徑得根據(jù)自己的環(huán)境修改。
[root@naginx memcache-3.0.8]# /usr/local/php/bin/phpize
Configuring for:
PHP Api Version: 20100412
Zend Module Api No: 20100525
Zend Extension Api No: 220100525
4、開始安裝擴(kuò)展memcache
[root@naginx memcache-3.0.8]# ./configure --enable-memcache \
--with-php-config=/usr/local/php/bin/php-config --with-zlib-dir \
make && make install
安裝完成后,提示
Build complete.
Don't forget to run 'make test'.
Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/
5、最后修改php.ini文件,在zend之前加入如下代碼。
vim /usr/local/php/lib/php.ini
extension=/usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/memcache.so
6、重新啟動(dòng)php-fpm
kill -QUIT pid
/usr/local/php/sbin/php-fpm
7、通過phpinfo()可以查看memcached信息
8、啟動(dòng)memecached
./memcached -d -m 100 -l 192.168.1.120 -p 11211 -u root
9、測(cè)試
附php的memcache測(cè)試代碼:
<?php
$mem = new Memcache;
$mem->connect("192.168.1.120", 11211) or die("Could not connect");
$version = $mem->getVersion();
echo "Server's version: ".$version."<br/>\n";
$mem->set('hellokey', 'Hello World', 0, 600) or die("Failed to save data at the memcached server");
echo "Store data in the cache (data will expire in 600 seconds)<br/>\n";
$get_result = $mem->get('hellokey');
echo "$get_result is from memcached server.";
?>
查看命中結(jié)果
telnet 192.168.1.120 11211
輸入命令:status
memcached 緩存信息查看(主要是discuz 3(修改config_global.php的memcached配置信息)設(shè)置完成后的緩存信息)
stats cachedump 1 0
ITEM hellokey [11 b; 1441724619 s]
ITEM 8bwmS2_home_follow_2 [6 b; 1441810396 s]
ITEM 8bwmS2_pluginlanguage_system [0 b; 1441710021 s]
ITEM 8bwmS2_cronnextrun [10 b; 1441710021 s]
ITEM 8bwmS2_userapp [6 b; 1441710021 s]
ITEM 8bwmS2_magic [6 b; 1441710021 s]
ITEM 8bwmS2_attachtype [6 b; 1441710021 s]
ITEM 8bwmS2_relatedlink [6 b; 1441710021 s]
ITEM 8bwmS2_posttable_info [0 b; 1441710021 s]
ITEM 8bwmS2_threadtable_info [0 b; 1441710021 s]
ITEM 8bwmS2_plugin [6 b; 1441710021 s]
ITEM 8bwmS2_threadtableids [0 b; 1441710021 s]
ITEM 8bwmS2_domainwhitelist [6 b; 1441710021 s]
ITEM 8bwmS2_albumcategory [6 b; 1441710021 s]
ITEM 8bwmS2_forum_guide [6 b; 1441710021 s]
ITEM 8bwmS2_historyposts [3 b; 1441710021 s]
ITEM 8bwmS2_heats [6 b; 1441710021 s]
ITEM 8bwmS2_announcements [6 b; 1441710021 s]
ITEM 8bwmS2_adminmenu [6 b; 1441710021 s]
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。