centos6.5 Memcache的安装
2016-02-29 17:04
501 查看
Memcache的安装
1.分别下载memcached和libeventWget http://memcached.org/files/memcached-1.4.25.tar.gzwget https://cloud.github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz
2.先安装libevent:
# tar zxvf libevent-2.0.21-stable.tar.gz# cd libevent-2.0.21-stable
# ./configure --prefix=/usr
# make
# make install 3.测试libevent是否安装成功ls -al /usr/lib |grep libevent 4.安装memcached,同时需要安装中指定libevent的安装位置:
# tar zxvf memcached-1.2.0.tar.gz
# cd memcached-1.2.0
# ./configure --with-libevent=/usr
# make
# make install 5.测试是否成功安装memcached:
# ls -al /usr/local/bin/mem* 6.启动memcached/usr/local/bin/memcached -d -m 10 -u memcache -p 11211 -c 256 -P /tmp/memcached.pid
-d选项是启动一个守护进程,
-m是分配给Memcache使用的内存数量,单位是MB
-u是运行Memcache的用户,我这里是root,
-l是监听的服务器IP地址-p是设置Memcache监听的端口,最好是1024以上的端口,
-c选项是最大运行的并发连接数,默认是1024,按照你服务器的负载量来设定,
-P是设置保存Memcache的pid文件测试:#Telnet localhost 11211Trying 127.0.0.1...Connected to localhost.Escape character is '^]'.#set test 0 0 10#test_valueSTORED#get testVALUE test 0 10test_valueEND#quitConnection closed by foreign host. 7.关闭memcachedkill `cat /tmp/memcached.pid`安装memcache的php扩展 1.下载memcache:wget http://pecl.php.net/get/memcache-2.2.7.tgz 2.安装PHP的memcache扩展tar vxzf memcache-2.2.7.tgz
cd memcache-2.2.7
/usr/local/php/bin/phpize (yum安装的php执行/usr/bin/phpize)
./configure –enable-memcache --with-php-config=/usr/local/php/bin/php-config --with-zlib-dir (yum安装的php执行 ./configure --enable-memcache --with-php-config=/usr/bin/php-config --with-zlib-dir)
make
make install 若没有phpize命令 yum install php-devel 3.上述安装完后会有类似这样的提示:Installing shared extensions: /usr/lib64/php/modules/ 4.修改/etc/php.iniextension_dir = "/usr/lib64/php/modules/"extension=memcache.so 5.重新启动apache,启动memcachedservice httpd restart运行下面的php文件,如果有输出hello world!,表示环境搭建成功<?php$mem = new Memcache;$mem->connect('127.0.0.1',11211);$mem->set('test','hello world!',0,10);$val = $mem->get('test');echo $val;?>
1.分别下载memcached和libeventWget http://memcached.org/files/memcached-1.4.25.tar.gzwget https://cloud.github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz
2.先安装libevent:
# tar zxvf libevent-2.0.21-stable.tar.gz# cd libevent-2.0.21-stable
# ./configure --prefix=/usr
# make
# make install 3.测试libevent是否安装成功ls -al /usr/lib |grep libevent 4.安装memcached,同时需要安装中指定libevent的安装位置:
# tar zxvf memcached-1.2.0.tar.gz
# cd memcached-1.2.0
# ./configure --with-libevent=/usr
# make
# make install 5.测试是否成功安装memcached:
# ls -al /usr/local/bin/mem* 6.启动memcached/usr/local/bin/memcached -d -m 10 -u memcache -p 11211 -c 256 -P /tmp/memcached.pid
-d选项是启动一个守护进程,
-m是分配给Memcache使用的内存数量,单位是MB
-u是运行Memcache的用户,我这里是root,
-l是监听的服务器IP地址-p是设置Memcache监听的端口,最好是1024以上的端口,
-c选项是最大运行的并发连接数,默认是1024,按照你服务器的负载量来设定,
-P是设置保存Memcache的pid文件测试:#Telnet localhost 11211Trying 127.0.0.1...Connected to localhost.Escape character is '^]'.#set test 0 0 10#test_valueSTORED#get testVALUE test 0 10test_valueEND#quitConnection closed by foreign host. 7.关闭memcachedkill `cat /tmp/memcached.pid`安装memcache的php扩展 1.下载memcache:wget http://pecl.php.net/get/memcache-2.2.7.tgz 2.安装PHP的memcache扩展tar vxzf memcache-2.2.7.tgz
cd memcache-2.2.7
/usr/local/php/bin/phpize (yum安装的php执行/usr/bin/phpize)
./configure –enable-memcache --with-php-config=/usr/local/php/bin/php-config --with-zlib-dir (yum安装的php执行 ./configure --enable-memcache --with-php-config=/usr/bin/php-config --with-zlib-dir)
make
make install 若没有phpize命令 yum install php-devel 3.上述安装完后会有类似这样的提示:Installing shared extensions: /usr/lib64/php/modules/ 4.修改/etc/php.iniextension_dir = "/usr/lib64/php/modules/"extension=memcache.so 5.重新启动apache,启动memcachedservice httpd restart运行下面的php文件,如果有输出hello world!,表示环境搭建成功<?php$mem = new Memcache;$mem->connect('127.0.0.1',11211);$mem->set('test','hello world!',0,10);$val = $mem->get('test');echo $val;?>
相关文章推荐
- Linux socket 初步
- Linux Kernel 4.0 RC5 发布!
- linux lsof详解
- linux 文件权限
- Linux 执行数学运算
- 10 篇对初学者和专家都有用的 Linux 命令教程
- Linux 与 Windows 对UNICODE 的处理方式
- Ubuntu12.04下QQ完美走起啊!走起啊!有木有啊!
- 解決Linux下Android开发真机调试设备不被识别问题
- 运维入门
- 运维提升
- Linux 自检和 SystemTap
- Ubuntu Linux使用体验
- c语言实现hashmap(转载)
- Linux 信号signal处理机制
- linux下mysql添加用户
- Scientific Linux 5.5 图形安装教程