Centos 6.6(X64位)系统编译安装memcached 并安装PHP的memcache扩展
来源:互联网 发布:泉州金蝶软件 编辑:程序博客网 时间:2024/05/19 06:17
第一步下载安装需要的包:
libevent-2.0.22-stable.tar.gz(http://libevent.org/)这个是memcache的支持包
memcached-1.4.24.tar(http://memcached.org/)
第二步:安装 libevent
# tar zxvf libevent-2.0.22-stable.tar.gz # cd libevent-2.0.22-stable # mkdir /usr/local/libevent # ./configure --prefix=/usr/local/libevent/ # make && make instal
第三步:安装memcached
# tar zxvf memcached-1.4.24.tar.gz
# cd memcached-1.4.24
# mkdir
# ./configure --prefix=/usr/local/memcached/ --with-libevent=/usr/local/libevent/
# make && make install
第四步:设置memcached开机启动
# vi /etc/rc.d/init.d/memcached
将以下内容写入
#!/bin/sh # # memcached: MemCached Daemon # # chkconfig: - 90 25 # description: MemCached Daemon # # Source function library. . /etc/rc.d/init.d/functions . /etc/sysconfig/network #[ ${NETWORKING} = "no" ] && exit 0 #[ -r /etc/sysconfig/dund ] || exit 0 #. /etc/sysconfig/dund #[ -z "$DUNDARGS" ] && exit 0 start() { echo -n $"Starting memcached: " daemon $MEMCACHED -u root-d -m 128 -l 127.0.0.100 -p 11211 -c 128 -P /tmp/memcached.pid echo } stop() { echo -n $"Shutting down memcached: " killproc memcached echo } MEMCACHED="/usr/local/memcached/bin/memcached" [ -f $MEMCACHED ] || exit 1 # See how we were called. case "$1" in start) start ;; stop) stop ;; restart) stop sleep 3 start ;; *) echo $"Usage: $0 {start|stop|restart}" exit 1 esac exit 0
保存
最后,添加Memcached开机启动
# cd /etc/rc.d/init.d/
# chmod 777 memcached
# chkconfig --add memcached
# chkconfig --level 2345 memcached on
# service memcached start(启动)# service memcached stop(关闭)# service memcached restart(重启)
接下来是为PHP安装memcache扩展:
# wget http://pecl.php.net/get/memcache-2.2.7.tgz
# zxf memcache-2.2.7.tgz # cd memcache-2.2.7 # /usr/local/php/bin/phpize # ./configure --with-php-config=/usr/local/php/bin/php-config --enable-memcache # make # make install显示 Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-zts-20131226/
最后将如下配置信息添加到php.ini文件中:
extension_dir = "/usr/local/php/lib/php/extensions/no-debug-zts-20131226/"
extension=memcache.so
备注:/usr/local/php/lib/php/extensions/no-debug-zts-20131226/这个路径可能会有不同,以您机器中的为准。
最后重启 httpd service httpd restart
查看phpinfo 会看到 memcache 扩展就说明安装成功
测试代码
<?php$memcache = new Memcache; //创建一个memcache对象 $memcache->connect('127.0.0.1', 11211) or die ("Could not connect"); //连接Memcached服务器 $memcache->set('key', 'test'); //设置一个变量到内存中,名称是key 值是test $get_value = $memcache->get('key'); //从内存中取出key的值 echo $get_value;?>
参考网址:http://www.111cn.net/sys/CentOS/58463.htm
http://blog.sina.com.cn/s/blog_46f7bb6d0101f55a.html
0 0
- Centos 6.6(X64位)系统编译安装memcached 并安装PHP的memcache扩展
- CentOS安装memcached及配置php的memcache扩展
- 编译安装libevent,memcache,以及php的memcached扩展
- 编译安装libevent,memcache,以及php的memcached扩展
- 编译安装libevent,memcache,以及php的memcached扩展
- CentOS 下编译安装php memcached扩展
- Centos 6.6(X64位)系统编译安装Apache服务器
- Centos 6.6(X64位)系统编译安装MySQL5.6源码
- Centos 6.6(X64位)系统编译安装PHP5.6.8教程
- centos系统为php安装memcached扩展
- centos yum安装memcached及php memcache扩展
- centos yum安装memcached及php memcache扩展
- Linux中搭建memcached,并为php安装memcache扩展
- linux centos 安装php的memcache扩展
- Centos 6.6(x64位)系统 Github安装
- CentOS 安装memcached php扩展
- centos安装php扩展memcached
- PHP编译安装memcache扩展
- R软件学习笔记-5(R软件画图)
- Google 推出的 Java 编码规范
- 女神教你字符串——导字符串(回文)
- 从control file 和 datafile header上获得不同的scn信息
- FZU 1889 水
- Centos 6.6(X64位)系统编译安装memcached 并安装PHP的memcache扩展
- 2013年蓝桥杯决赛试题
- windows读取bmp格式图像代码移植linux;windows代码移植linux,数据类型不匹配我问题;
- 《推荐系统实践》的笔记
- JM代码分析(二)
- 第九周 项目二
- Joseph(1443)
- html中表格table冻结行和列
- html css学习笔记-响应式布局的两种基本实现