安装php扩展模块参数memcache和memcached在php中的应用
一, memcache和memcached的区别与关系统
php要想去访问memcached就得需要memcache扩展,这个道理和php连接mysql一样。 你不安装memcache扩展就没法识别memcache协议。php安装memcache扩展后,还需要安装memcached服务。 php相当于客户端,memcached相当于服务端
查看php安装的模块命令:/usr/local/php/bin/php –m
memcache在php中编译
memcache在php中编译
1 .安装memcache
wget http://www.lishiming.net/data/attachment/forum/memcache-2.2.3.tgz
# tar zxvf memcache-2.2.3.tgz
# cd memcache-2.2.3
# /usr/local/php/bin/phpize
如果执行这上面的命令报错:
phpize:Cannot find autoconf. Please check your autoconf installation and the $PHP_AUTOCONF envir (2012-06-26 14:37:00)
根据网上的解决办法是: # cd /usr/src # wget http://ftp.gnu.org/gnu/m4/m4-1.4.9.tar.gz
# tar -zvxf m4-1.4.9.tar.gz # cd m4-1.4.9/
# ./configure && make && make install # cd ../
# wget http://ftp.gnu.org/gnu/autoconf/autoconf-2.62.tar.gz
# tar -zvxf autoconf-2.62.tar.gz # cd autoconf-2.62/
# ./configure && make && make install
可爱的yum让我更容易把没安装的包安装好 yum install m4 yum install autoconf
可以参考博客:http://www.cnblogs.com/keethebest/archive/2013/05/30/3108621.html
# ./configure --with-php-config=/usr/local/php/bin/php-config
# make
# make install
# cp modules/memcache.so /usr/local/php/ext/ //把memcache.so 拷贝至php的extension_dir下,#查看php extension_dir的方法是 /usr/local/php/bin/php -i |grep extension_dir
修改扩展路径,在php.ini中修改:
extension_dir = "/usr/local/php/ext"
然后在php.ini 中添加
extension = memcache.so
保存后可以利用 /usr/local/php/bin/php -m 检测和查看具体的参数
memcached 的编译安装或也可以使用phpinfo()函数查看具体信息:
2 安装memcached
wget http://memcached.org/files/memcached-1.4.24.tar.gz
tar zxvf memcached-1.4.24.tar.gz
cd memcached-1.4.24
./configure --prefix=/usr/local/memcached
报错:缺少libevent库
yum install –y libevent*
make && make install
启动:
/usr/local/memcached/bin/memcached -m 2048 -p 11211 -l 127.0.0.1 -d -u www
-m 后边指定memecached使用多少内存,单位是M
-p 指定memcached 启动端口
-l 指定绑定的IP
-u 指定以某个账户的身份启动
3 最后用一个php测试程序来测试
vim /usr/local/apache2/htdocs/test.php
<?php
$mem = new Memcache;
$mem->connect("127.0.0.1", 11211);
//参数一是本机地址,当然也可是其他机器的地址,参数二是端口号
//保存数据
$mem->set('hello', 'hello world', 0, 60);
$val = $mem->get('hello');
echo $val;
?>
然后在浏览器里输入 本机IP/test.php
成功的话显示
hello world
参考博客:http://www.apelearn.com/bbs/forum.php?mod=viewthread&tid=8712&highlight=memcache
安装php扩展模块参数memcache和memcached在php中的应用的更多相关文章
- PHP与memcache和memcached以及安装使用
老规则,在作者寒冰讲之前我们要来明确memcache与memcached这两个东西到底是什么? 说法一: 两个不同版本的php的memcached的客户端 new memcache是pecl扩展库版本 ...
- memcache与memcached介绍及安装配置
也许大家一看到Memcache和Memcached会有点晕,这两者有什么关系又有什么区别呢,下面先给大家说下Memcached,Memcached是一个高性能的分布式内存对象缓存系统,用于动态Web应 ...
- PHP 7 安装 Memcache 和 Memcached 总结
Memcache 与 Memcached 的区别 Memcached 是 Memcache 的升级版,优化了 Memcache,并增加了一些操作方法.所以现在基本都是用最近版本的. PHP 7 下安装 ...
- ubuntu下安装memcache及memcached
memcache 和 memcached 有什么区别呢? memcache最早是在2004年2月开发的,而memcached最早是在2009年1月开发的.所以memcache的历史比memcached ...
- php7安装memcache 和 memcached 扩展
php7安装memcache 和 memcached 扩展 标签(空格分隔): php memcache和memcached区别 memcache:http://pecl.php.net/packag ...
- PHP7 下安装 memcache 和 memcached 扩展
转载自:https://www.jianshu.com/p/c06051207f6e Memcached 是高性能的分布式内存缓存服务器,而PHP memcache 和 memcached 都是 Me ...
- 【Linux】memcache和memcached的自动安装
赶时间所以写一个简单的一个脚本,没有优化,想优化的可以学习下shell,自己优化下. 且行且珍惜,源码包+脚本领取处 链接:https://pan.baidu.com/s/1wIFR1wY-luDKs ...
- 在linux中使用phpize安装php扩展模块
介绍:linux系统中,php安装成功后,在bin目录下会生成一个名叫phpize的可执行脚本,这个脚本的用途是动态安装php扩展模块.使用phpize脚本安装php扩展模块的好处:在安装php时没有 ...
- php扩展memcache和memcached区别?以及memcached软件的介绍
引用“http://www.vicenteforever.com/2012/03/memcache-different-memcached/” memcached是一个软件,而PHP包括了memcac ...
随机推荐
- BeanUtils Date
在jdbc封装(基础的CRUD)的时候(查询一条数据,查询多条数据,更新....)经常会用到一个BeanUtil来设置属性值,当对象中存在Date类型的时候,会报错:如下: 2017-11-03 13 ...
- 命令__cp、scp(Secure Copy)
cp命令:区别:硬链接原文件&链接文件公用一个inode号,说明他们是同一个文件,而软链接原文件&链接文件拥有不同的inode号,表明他们是两个不同的文件: 在文件属性上软链接明确写出 ...
- Codeforces Round #352 (Div. 2) B
B. Different is Good time limit per test 2 seconds memory limit per test 256 megabytes input standar ...
- code forces 990C
http://codeforces.com/contest/990/problem/C C. Bracket Sequences Concatenation Problem time limit pe ...
- hadoop学习之HDFS
1.什么是大数据?什么是云计算?什么是hadoop? 大数据现在很火,到底什么是大数据,多大的数据才算大,一般而言对于TB级以上的数据我们成为大数据,对于这些数据它的价值在哪?大数据的价值就是我们大量 ...
- 让Vs2010支持 Css3+HTML5
第一步. 先到微软官方下载一个 Microsoft Visual Studio 2010 sp1 . 给传送门:.microsoft.com/downloads/zh-cn/details.aspx? ...
- Aspose.Cells 基础用法
最近使用Aspose.Cells做Excel,在怎么添加批注和添加内部导航链接上耗费了一些时间,最后在官网上找到相关用法,记录一下. 代码不用过多介绍,看看即可明白. 测试代码下载 Workbook ...
- 在eclipse中使用vim
转自:http://blog.csdn.net/eplaylity/article/details/6168283 1. vrapper(开源) 直接从eclipse安装即可,地址:http://vr ...
- protobuf 中的嵌套消息的使用 主要对set_allocated_和mutable_的使用
protobuf的简单的使用,不过还留下了一个问题,那就是之前主要介绍的都是对简单数据的赋值,简单数据直接采用set_xx()即可,但是如果不是简单变量而是自定义的复合类型变量,就没有简单的set函数 ...
- python接口自动化7-参数关联【转载】
本篇转自博客:上海-悠悠 原文地址:http://www.cnblogs.com/yoyoketang/tag/python%E6%8E%A5%E5%8F%A3%E8%87%AA%E5%8A%A8%E ...