centos yum安裝memcached及php memcache擴充教程,centosmemcached

來源:互聯網
上載者:User

centos yum安裝memcached及php memcache擴充教程,centosmemcached

注意事項:

1 安裝時注意許可權問題 sudo

2 需先啟動memcache服務 php才能測試

Memcached是高效能的,分布式的記憶體對象緩衝系統,用於在Live App中減少資料庫負載,提升訪問速度。

開始安裝memcache

尋找相關軟體包

#yum search memcache

有了,現在可以安裝了

#yum -y install –enablerepo=rpmforge memcached php-pecl-memcache

#如果提示沒安裝成功 yum update一下 然後再執行命令 成功即把memcache服務端和php memcache擴充都安裝好 會在/usr/lib64/php/modules/memcache.so

Loaded plugins: fastestmirror, security

Loading mirror speeds from cached hostfile

* atomic: mirrors.neusoft.edu.cn

* base: mirrors.btte.net

* extras: mirrors.yun-idc.com

* updates: mirrors.btte.net

Setting up Install Process

Error: Nothing to do

驗證一下安裝結果

#memcached -h

#php -m|grep memcache

設定開機啟動

#chkconfig memcached on

啟動memcached

#service memcached start

到這裡memcache服務端安裝成功 測試安裝是否成功

[root@localhost usr]# php -m|grep memcache

memcache

[root@localhost usr]# lsof -i tcp:11211

COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME

memcached 3399 memcached 26u IPv4 12677364 0t0 TCP *:memcache (LISTEN)

memcached 3399 memcached 27u IPv6 12677365 0t0 TCP *:memcache (LISTEN)

已經在偵聽 說明成功 會產生memcache.so 32位在/usr/lib/中 64位在/usr/lib64/

接下來載入php memcache擴充

php.ini中開啟 extension=/usr/lib64/php/modules/memcache.so

/etc/init.d/httpd restart #重啟Apache

需先啟動memcache 然後重啟php-fpm 即可看到擴充 不需重啟nginx

service php-fpm restart

代碼測試:

mem.php

$mem = new Memcache;

$mem->connect("127.0.0.1", 11211);

$mem->set('key', 'This is a test2211!', 0, 60);

$val = $mem->get('key');

echo $val;

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.