這篇文章主要介紹了centos系統爲php安裝memcached擴展的步驟,你們參考使用吧
1. 經過yum安裝php
yum -y install memcached
#安裝完成後執行:
memcached -h
#出現memcached幫助信息說明安裝成功c++
2. 加入啓動服務vim
chkconfig --level 2345 memcached oncentos
3. 配置Memcachedmemcached
vim /etc/sysconfig/memcached
#文件中內容以下,按須要修改:
PORT="11211" #端口
USER="root" #用戶名
MAXCONN="1024" #最大鏈接數
CACHESIZE="64" #內存大小
OPTIONS="" #附加參數ui
4. 安裝libmemachedspa
wget https://launchpad.net/libmemcached/1.0/1.0.16/+download/libmemcached-1.0.16.tar.gz
tar -zxvf libmemcached-1.0.16.tar.gz
cd libmemcached-1.0.16
./configure -prefix=/usr/local/libmemcached -with-memcached
make && make install
注意:這裏容易報錯,
編譯錯誤:
libmemcached/auto.cc: In function 'memcached_return_t text_incr_decr(memcached_server_st*, bool, const char*, size_t, uint64_t, bool)':
libmemcached/auto.cc:73: error: expected `)' before 'PRIu64'.net
In file included from ./libmemcached/common.h:72,
from ./libmemcached/csl/common.h:40,
from libmemcached/csl/context.cc:38:
./libmemcached-1.0/memcached.h:46:27: error: tr1/cinttypes: No such file or directory
緣由是gcc版本太低了
對策:libmemcached-1.0.2 版本以上升級編譯器版本
# yum install gcc44 gcc44-c++ libstdc++44-develorm
# export CC=/usr/bin/gcc44
# export CXX=/usr/bin/g++44
# ./configureserver
若是升級gcc版本出現鏈接源的問題不能下載,能夠換用163的yum源,參考文章
http://back.zhizhi123.com/?p=109
5. 安裝php-devel
yum install php-devel
6. 安裝PHP Memcached擴展
wget http://pecl.php.net/get/memcached-2.1.0.tgztar -zxvf memcached-2.1.0.tgzcd memcached-2.1.0/usr/local/php/bin/phpize./configure -enable-memcached -with-php-config=/usr/local/php/bin/php-config -with-zlib-dir -with-libmemcached-dir=/usr/local/libmemcached -prefix=/usr/local/phpmemcachedmake && make install