安装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. 进阶之路(基础篇) - 019 Serial串口函数说明

    本文总结了Arduino常用串口操作函数,函数说明部分来源于Arduino 官网串口使用指南,示例与实验部分为自编.本文是对Arduino串口操作函数的较全面总结,可作为工具贴查找使用. 函数:if( ...

  2. EF的表左连接方法Include和Join

    在EF中表连接常用的有Join()和Include(),两者都可以实现两张表的连接,但又有所不同. 例如有个唱片表Album(AlbumId,Name,CreateDate,GenreId),表中含外 ...

  3. C#项目中引入app.manifest管理员权限运行

    原文地址:https://blog.csdn.net/qq395537505/article/details/51010962 参考UAC:User Account Control 参考IE保护模式: ...

  4. 学习asp.net的流程

    如果你已经有较多的面向对象开发经验,跳过以下这两步: 第一步 掌握一门.NET面向对象语言,C#或VB.NET 我强烈反对在没系统学过一门面向对象(OO)语言的前提下去学ASP.NET. ASP.NE ...

  5. 认识LINQ的第一步---从查询表达式开始

    学习和使用C#已经有2个月了,在这两个月的学习中,深刻体会到,C#这门语言还真不适合编程初学者学习,因为它是吸取了很多其他语言,不仅是面向对象,还包括函数式语言的很多特性,导致它变成特性大爆炸的语言. ...

  6. 64位平台C/C++开发注意事项

    在http://www.viva64.com/en/l/上例出了28个在64位平台上使用C/C++开发的注意事项,对于进入64位时代的程序员应该去看看这28个事项,这些英文读物对于有C/C++功底的朋 ...

  7. kafaka学习

    创建一个topic: [root@hdp1 bin]# ./kafka-topics. --replication-factor --partitions --topic justin Created ...

  8. MySQL 5.6学习笔记(运算符)

    MySQL运算符包括四类:算术运算符.比较运算符.逻辑运算符和位运算符. 1. 算术运算符 用于种类数值运算.包括:加(+).减(-).乘(*).除(/).取余(%). 除法除数为零时,执行结果为nu ...

  9. ios. GCD 倒计时时间

    //倒计时时间 __block int timeout = 60; dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_ ...

  10. Android 架构师技能图谱(转载)

    架构与设计 设计模式 重构 技术选型 特性 可用性 性能 包大小 方法数 文档 技术支持 UI架构模式 MVC MVP MVVM 研发工具 集成开发环境 Android Studio Sublime ...