Memcached简单安装
1. 安装libevent1
2
3
4
5
6
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
1
2
3
4
5
6
7
8
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支持
1
2
3
4
5
6
7
8
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
1
2
kill -HUP `cat /usr/local/nginx/logs/nginx.pid`
kill -USR2 `cat /usr/local/php/var/run/php-fpm.pid`
页:
[1]