Memcached簡單安裝

1. 安裝libevent

wget https://sourceforge.net/projects/levent/files/libevent/libevent-2.0/libevent-2.0.22-stable.tar.gz --no-check-certificate
tar zxvf libevent-2.0.22-stable.tar.gz -C /usr/src/
cd /usr/src/libevent-2.0.22-stable
./configure --prefix=/usr/local/libevent
make
make install

2. 安裝memcached

tar zxvf memcached-1.4.22.tar.gz -C /usr/src/ 
cd /usr/src/memcached-1.4.22
./configure --prefix=/usr/local/memcached --with-libevent=/usr/local/libevent
make
make install
useradd memcache -s /sbin/nologin
chown -R memcache:memcache /usr/local/memcached/
/usr/local/memcached/bin/memcached -u memcache -m 1024 -l 192.168.20.12 -p 1340 -c 2000 -d -P /tmp/memcached.pid

啓動參數說明:

-u 指定啓動用戶

-m 指定使用多少內存

-l 指定監聽地址

-p 指定監聽端口

-c 指定最大同時連接數

-d 以守護進程方式運行(在後臺運行)

-P 指定存放PID的文件

-h 查看幫助信息


3. php添加memcache支持

tar zxvf memcache-2.2.7.tgz -C /usr/src/
cd /usr/src/memcache-2.2.7
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config --enable-memcache
make
make install
vi /usr/local/php/etc/php.ini
extension=memcache.so      //添加

4. 重啓nginx、php

kill -HUP `cat /usr/local/nginx/logs/nginx.pid`
kill -USR2 `cat /usr/local/php/var/run/php-fpm.pid`


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章