安装memcache

yum install memcached  

安装libmemcached库

yum install libmemcached

PHP安装Memcache扩展

root@blog.phpha.com] wget -c http://pecl.php.net/get/memcache-3.0.8.tgz
[root@blog.phpha.com] tar -zxvf memcache-3.0.8.tgz
[root@blog.phpha.com] cd memcache-3.0.8
[root@blog.phpha.com] /usr/local/php/bin/phpize
[root@blog.phpha.com] ./configure -with-php-config=/usr/bin/php-config -with-zlib-dir
[root@blog.phpha.com] make && make install
#Installing shared extensions: /usr/lib64/php/modules/
#/usr/lib64/php/modules/memcache.so
[root@blog.phpha.com] vim /etc/php.ini
#extension = /usr/lib64/php/modules/memcache.so
[root@blog.phpha.com] service php-fpm reload

启动

memcached -d -u root -p 11211

测试:

<?php

$mem = new Memcache;

$mem->addServer("localhost",11211);

echo "Version:".$mem->getVersion();

class testClass{

        private $str_attr;
private $int_attr; public function __construct($str,$int)
{
$this->str_attr = $str;
$this->int_attr = $int;
} public function set_str($str)
{
$this->str_attr = $str;
}
public function set_int($int)
{
$this->int_attr = $int;
} public function get_str()
{
return $this->str_attr;
}
public function get_int()
{
return $this->int_attr;
}
} $test = new testClass("hell world",1123);
$mem->set("key",$test,false,1000); var_dump($mem->get("key")); $test_array = array("index_1"=>"hello","index_2"=>"world"); $mem->set("array_test",$test_array,false); var_dump($mem->get("array_test")); ?>

问题:

1.找不到php-config

find / -name php-config

2.找不到 ZLIB memcache support requires ZLIB

yum install zlib-devel

3.can't run as root without the -u switch

memecached -u root start

参考:

centos 为php安装memcache.http://blog.csdn.net/php_boy/article/details/6880488

CentOS环境PHP安装memcache扩展.http://blog.phpha.com/archives/1554.html

Centos安装Memcache.http://www.cnblogs.com/wubaiqing/archive/2011/09/19/2181602.html

CentOS环境PHP安装memcache扩展的更多相关文章

  1. win10 64位安装memcache扩展和开启redis扩展

    前面有关于win10下搭建wamp环境的介绍,在此不在赘述,php操作memcache有memcache库和memcached库,其中memcache是php内置的扩展库,支持面向对象和面向过程两种操 ...

  2. linux下搭建lamp环境以及安装swoole扩展

    linux下搭建lamp环境以及安装swoole扩展   一.CentOS 6.5使用yum快速搭建LAMP环境 准备工作:先更新一下yum源  我安装的环境是:apache2.2.15+mysql5 ...

  3. linux-CentOS6.4安装Memcached+memcached扩展+安装memcache扩展+Memcache+mecached同步SESSION的几种方法

    一.编译环境的准备 yum install gcc  yum install gcc-c++ libstdc++-devel  yum install zlib-devel 二.源代码包准备 wget ...

  4. linux php 安装 memcache 扩展

    1. memcached依赖于libevent,需要先安装libevent. tar zxvf libevent-2.0.21-stable.tar.gz cd libevent-2.0.21-sta ...

  5. phpStudy下安装memcache扩展

    简要:参考<phpStydy配置memcache扩展>,期间安装不到memcache;为此向大家分享我遇到的问题和解决办法,希望能够跟各位PHP大神学习探索,如果有不对或者好的建议告知下: ...

  6. CentOS环境Docker安装教程(官方推荐的docker三种方式安装)

    CentOS环境Docker安装教程(官方推荐的docker三种方式安装) 一.使用yum方式安装 1.安装依赖包 $ sudo yum install -y yum-utils device-map ...

  7. 安装memcached服务 和 php 安装memcache扩展

    这是所有的命令,至于哪个命令是干嘛的自己悟去吧  ,顺便穿插一些知识点 安装libevent cd /home/ wget  http://www.monkey.org/~provos/libeven ...

  8. CentOS下php安装mcrypt扩展

    CentOS下php安装mcrypt扩展 Posted on 2012-09-12 15:27 C'est la vie 阅读(48294) 评论(3) 编辑 收藏 (以下步骤均为本人实际操作,可能与 ...

  9. php 安装Memcache扩展

    转载地址:http://www.tuicool.com/articles/EB3imm 文章概述:由于当前机器安装的php,是用yum安装,现在需要使用到memadmin做一些监控, memadmin ...

随机推荐

  1. 【HTML】前端性能优化之CDN和WPO的比较

    CDN通过将资源存储在更接近用户的位置,缩短到服务器的往返行程,加快页面加载时间来解决性能问题.WPO解决方案,如Radware的FastView,则在前端进行性能提升处理,使页面更有效地呈现在浏览器 ...

  2. 两段检验系统生成的identityHashCode是否重复的代码

    前言:承接上一篇hashCode和identityHashCode 的关系,下面的两段简单的程序主要是检验一下系统生成的identityHashCode是否存在重复的情况. 1:可以自由控制生成对象的 ...

  3. sql中union 和 union all的区别

    最近发现一个视图出奇的慢,在生产环境还好,由于服务器配置较高,没有察觉出来.但是做了一次修改后在开发版 和测试版就直接查询不出结果了.就连select count(1) from 都运行2个小时没有结 ...

  4. mysql 查询 根据时分秒取数据 比如 取 时间为 8点半的 dateformat 时间函数转换

     date_format(date,'%H') = 8 and date_format(date,'%i') = 30   SELECT * FROM `t_pda_trucklog` WHERE D ...

  5. SpringBoot多跨域请求的支持(JSONP)

    在我们做项目的过程中,有可能会遇到跨域请求,所以需要我们自己组装支持跨域请求的JSONP数据,而在4.1版本以后的SpringMVC中,为我们提供了一个AbstractJsonpResponseBod ...

  6. C# 类中索引器的使用

    索引器(Indexer)是C#引入的一个新型的类成员,它使得类中的对象可以像数组那样方便.直观的被引用.索引器非常类似于属性,但索引器可以有参数列表,且只能作用在实例对象上,而不能在类上直接作用.定义 ...

  7. STM8串口初始化寄存器配置

    //库函数配置 UART1_DeInit(); UART1_Init((u32)1000000, UART1_WORDLENGTH_8D, UART1_STOPBITS_1, \ UART1_PARI ...

  8. 交叉验证(CrossValidation)方法思想简介[zz]

    以下简称交叉验证(Cross Validation)为CV.CV是用来验证分类器的性能一种统计分析方法,基本思想是把在某种意义下将原始数据(dataset)进行分组,一部分做为训练集(train se ...

  9. ubuntu18.04分辨率

    一.使用xrandr命令可以查询当前的显示状态.找出被连接的显示器名称:VGA-1 jack@noi:~$ xrandr Screen : minimum x , current x , maximu ...

  10. [IOS]开源库RegexKitLite正则表达式的使用

    1.去RegexKitLite下载类库,解压出来会有一个例子包及2个文件,其实用到的就这2个文件,添加到工程中. 2.工程中添加libicucore.dylib frameworks. 友情提醒:一般 ...