添加php的memcached擴充模組

來源:互聯網
上載者:User

標籤:

 

memcached服務直接用yum安裝
[[email protected] ~]# yum install memcached

然後啟動memcache服務,啟動多個執行個體
[[email protected] ~]# /usr/bin/memcached -d -m 512 -p 11211 -u memcached -c 1024
[[email protected] ~]# /usr/bin/memcached -d -m 512 -p 11212 -u memcached -c 1024
[[email protected] ~]# /usr/bin/memcached -d -m 512 -p 11266 -u memcached -c 1024

[[email protected] ~]# ps -ef|grep memcached
root 2228 32759 0 19:15 pts/2 00:00:00 grep --color memcached
495 2713 1 0 Jun12 ? 00:04:04 /usr/bin/memcached -d -m 512 -p 11211 -u memcached -c 1024
495 2720 1 0 Jun12 ? 00:05:10 /usr/bin/memcached -d -m 512 -p 11212 -u memcached -c 1024
495 2727 1 0 Jun12 ? 00:07:10 /usr/bin/memcached -d -m 512 -p 11266 -u memcached -c 1024

查看memcached版本
[[email protected] ~]# memcached -h|head -1
memcached 1.4.4

這個1.4.4版本的memcached就是本機程式使用的快取服務。

---------------------------------------------------------------------------------

由於之前安裝了php服務,後續需要手動添加memcached擴充模組。

php擴充模組安裝使用的是2.2.0版本的memcached

1)首先安裝memcached的庫libmemcached
[[email protected] ~]# https://launchpadlibrarian.net/165454254/libmemcached-1.0.18.tar.gz
[[email protected] ~]# tar -zvxf libmemcached-1.0.18.tar.gz
[[email protected] ~]# cd libmemcached-1.0.18
[[email protected] libmemcached-1.0.18]# ./configure --prefix=/usr/local/libmemcached --with-memcached
[[email protected] libmemcached-1.0.18]# make && make install

2)接著安裝memcached
[[email protected] ~]# wget http://pecl.php.net/get/memcached-2.2.0.tgz
[[email protected] ~]# tar -zvxf memcached-2.2.0.tgz
[[email protected] ~]# cd memcached-2.2.0
[[email protected] memcached-2.2.0]# /usr/local/php5.6.26/bin/phpize #使用phpize命令產生一個configure檔案
[[email protected] memcached-2.2.0]# ./configure --with-php-config=/usr/local/php5.6.26/bin/php-config --with-libmemcached-dir=/usr/local/libmemcached
[[email protected] memcached-2.2.0]# make && make install

安裝完成後,會產生一個memcached.so檔案,這個檔案需要在php.ini設定檔裡添加

安裝php5.6.26後,得知擴充檔案路徑存放在/usr/loca/php5.6.26/lib/php/extensions/no-debug-non-zts-20131226/
然後將上面編譯產生的memcached.so檔案放到/usr/loca/php5.6.26/lib/php/extensions/no-debug-non-zts-20131226/

編譯php.ini檔案
[[email protected] ~]# vim /usr/loca/php5.6.26/etc/php.ini
....
extension="/usr/loca/php5.6.26/lib/php/extensions/no-debug-non-zts-20131226/memcached.so"


然後重啟php
[[email protected] ~]# pkill -9 php-fpm
[[email protected] ~]# /usr/loca/php5.6.26/sbin/php-fpm

然後查看php的擴充模組
[[email protected] etc]# /usr/loca/php5.6.26/bin/php -m
......
memcached

添加php的memcached擴充模組

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.