一 安装libevent

1.去官网http://libevent.org/ 下载最新源码,我用的是libevent-2.0.20-stable.tar.gz

2.解压到/usr/src目录 ,执行命令:sudo tar -zxvf libevent-2.0.20-stable.tar.gz -C /usr/src

3.进入解压以后的目录,用sudo方式执行命令:sudo ./configure --prefix=/usr/local/libevent ; make ; make install

二 安装memcache

1.去官网 http://memcached.org/ 下最新源码,我用的是memcached-1.4.15.tar.gz

2.解压到/usr/src目录 ,执行命令:sudo tar -zxvf memcached-1.4.15.tar.gz -C /usr/src

3.进入解压以后的目录,用sudo方式执行命令:sudo ./configure --prefix=/usr/local/memcached --with-libevent=/usr/local/libevent; make ; make install

三 安装php的memcache扩展

有两个版本一个是memcache(http://pecl.php.net/package/memcache ),另一个是基于libmemcached的memcached版本(http://pecl.php.net/package/memcached );

网上查的资料是说前一个是原生的,后一个比前一个功能更强大。比较推荐使用基于libmemcahced 库的memcached扩展。支持memcache提供的CAS操作,稳定性和效率也更好。

这里我使用基于libmemcached 库的memcached扩展,安装步骤如下:

首先,安装libmemcached库

1.去网址 https://launchpad.net/libmemcached (或者http://libmemcached.org/libMemcached.html )下载源码,

我用的是libmemcached-1.0.14.tar.gz

2.解压缩到/usr/src目录,用sudo方式执行命令:sudo tar -zxvf libmemcached-1.0.14.tar.gz -C /usr/src

3.进入目录/usr/src/libmemcached-1.0.14/,sudo方式执行命令:./configure ;make;make install (不加--prefix=/usr/local/libmemcached 指定安装目录时,libmemcached 默认安装在/usr/local/,头文件安装在/usr/local/include/libmemcachde/,动态库默认安装在/usr/local/lib/下。)

4.make时遇到问题:sorry, unimplemented: Graphite loop optimizations can only be used if the libcloog-ppl0 package is installed。解决办法是修改Makefile,查找并去掉 floop-parallelize-all(应该有两处需要去掉),看了网上资料说是去掉后表示不使用Graphite loop 优化。

5.再次make,遇到问题:fatal error: sasl/sasl.h: No such file or directory. 在网上搜到的解决办法是:

Depending on your operating system, you'll need to install the cyrus-sasl development package.

That would be cyrus-sasl-devel on RedHat based distros and libsasl2-dev on Debian based distros IIRC.

我在ubuntu下直接用sudo apt-get install libsasl2-dev 安装了。

6.编译还是遇到问题,显示无法链接到sasl的一些文件。问题显示如下:

undefined reference to `sasl_client_step'
   undefined reference to `sasl_dispose'
   undefined reference to `sasl_client_start'
   undefined reference to `sasl_client_new'

解决办法是重新执行configure命令,增加相应的参数。sudo执行命令:sudo ./configure
--enable-sasl --without-memcached LDFLAGS=-Wl,--as-neede ;make; make
install

7.终于安装libmemcached库成功了。。。

其次,安装memcached版本的php扩展

1. 去网址http://pecl.php.net/package/memcached 下载memcached版本,我用的是memcached-2.1.0.tgz

2. 解压到/usr/src目录 ,执行命令:sudo tar -zxvf memcached-2.1.0.tgz -C /usr/src

3. 进入解压以后的目录,是没有configure文件的,用sudo方式执行命令来生成:sudo /usr/local/php/bin/phpize

4.遇到问题:Cannot find autoconf. Please check your autoconf installation
and the $PHP_AUTOCONF environment variable. Then, rerun this script.
网上搜到的解决办法为:

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

5.这是再次执行sudo /usr/local/php/bin/phpize,就可以成功生成configure文件了。(phpize是用来扩展php扩展模块的,通过phpize可以建立php的外挂模块,官方说明网址为:http://php.net/manual/en/install.pecl.phpize.php)

6.用sudo方式执行命令./configure --with-php-config=/usr/local/php/bin/php-config; make ; make install

7.编译完成了,还需要做的是在/usr/local/lib/php.ini文件中加入extension值:extension=memcache.so

8.重启/usr/local/php/sbin/php-fpm程序使配置生效,但是报错:

ERROR: failed to open configuration file '/usr/local/php/etc/php-fpm.conf': No such file or directory (2)

ERROR: failed to load configuration file '/usr/local/php/etc/php-fpm.conf'

ERROR: FPM initialization failed

解决办法为: (1)cd /usr/local/php/etc/; (2)mv php-fpm.conf.default php-fpm.conf

9.重启仍然出现问题:ERROR: [pool www] cannot get uid for user 'www'。解决办法为:编辑文件vim /usr/local/php/etc/php-fpm.conf,

把user = nobody group = nobody  中的nobody修改成有效的用户和用户组名称。

10.php扩展可使用的一些方法可参考网址:http://blog.csdn.net/fwkjdaghappy1/article/details/7592337

参考网址:

http://www.dewen.org/q/844

http://hi.baidu.com/thinkinginlamp/item/5a3b2531e25dc6f62784f4fb

http://code.google.com/p/memcached/wiki/PHPClientComparison

https://bugs.launchpad.net/keystone/+bug/843080

http://www.cppblog.com/kefeng/archive/2010/10/11/129422.html

https://bugs.launchpad.net/libmemcached/+bug/656010

http://blog.csdn.net/vaal_water/article/details/6439483

http://www.spiration.co.uk/post/1385/Cannot-find-autoconf.-Please-check-your-autoconf-installation

https://gist.github.com/3359828

http://www.2cto.com/kf/201111/110140.html

http://blog.johntechinfo.com/technology/264

http://www.oschina.net/question/231397_36921

http://www.cnblogs.com/huangjingzhou/articles/2093706.html

http://blog.csdn.net/fwkjdaghappy1/article/details/7592337

[转]编译安装libevent,memcache,以及php的memcached扩展的更多相关文章

  1. centos7.6编译安装php7.2.11及redis/memcached/rabbitmq/openssl/curl等常见扩展

    centos7.6编译安装php7..11及redis/memcached/rabbitmq/openssl/curl等常见扩展 获取Php的编译参数方法: [root@eus-api-cms-bac ...

  2. centOs编译安装php7.2支持微擎php扩展

    发现yum安装许多坑 于是只好编译安装 第一步得到镜像地址 在      https://www.php.net/downloads.php     有的地址比较慢,需要耐心等待 cd /usr/lo ...

  3. yum 安装apache php 使php支持memcached扩展

    在公司上新项目的时候,无论生产环境还是测试环境,都会让运维安装php 环境(lamp/lnmp),并让php支持memcached 的扩展.这里搭建php环境其实主要就是搭建apache 和php.m ...

  4. Linux下编译安装Memcache

    需要gcc,make,cmake,autoconf,libtool等工具,联网后,yum install -y gcc,make,cmake,autoconf,libtool 编译安装libevent ...

  5. CentOS6.3编译安装Memcached

    要用到如下源码包: /usr/local/src/memcached/libevent-2.0.21-stable.tar.gz /usr/local/src/memcached/memcached- ...

  6. centos7编译安装pgbouncer

    1.下载pgbouncer程序包和libevent依赖包 wget https://github.com/libevent/libevent/releases/download/release-2.1 ...

  7. ffmpeg源码编译安装(Compile ffmpeg with source) Part 2 : 扩展安装

    在Ubuntu,Debian,Mint上编译ffmpeg 本文主要为在Ubuntu,Debian和Mint上编译安装ffmpeg和库文件以及一些扩展的编解码器.当然这与从源中安装无关. 请首先看一下通 ...

  8. Centos7 编译安装 Nginx PHP Mariadb Memcache扩展 ZendOpcache扩展 (实测 笔记 Centos 7.0 + Mariadb 10.1.9 + Nginx 1.9.9 + PHP 5.5.30)

    环境: 系统硬件:vmware vsphere (CPU:2*4核,内存2G,双网卡) 系统版本:CentOS-7-x86_64-Minimal-1503-01.iso 安装步骤: 1.准备 1.1 ...

  9. Linux下memcache编译安装与基本使用

    memcache是一套分布式的高速缓存系统,特点为key-value 存储 一.在 linux 编译安装memcache.redis等,需要 gcc,make,cmake,autoconf,libto ...

随机推荐

  1. utf8转gbk,libcurl中文乱码处理

    这两个转码在网页客户端处理用很常见,所使用的平台为VS2010,字符集采用多字节字符集 utf8转gbk string UTF8ToGBK(const std::string& strUTF8 ...

  2. php 队列

    一.php中对共享内存,消息队列的操作 http://blog.csdn.net/haitun312366/article/details/8614797 二.PHP memcache 队列类 htt ...

  3. http://zh.lucida.me/

    一个很厉害的在美国Google的学长的博客

  4. Spring事务传播机制&隔离级别

    一.Propagation (事务的传播属性) Propagation : key属性确定代理应该给哪个方法增加事务行为.这样的属性最重要的部份是传播行为.有以下选项可供使用:PROPAGATION_ ...

  5. app的自动更新(调用DownloadManager)

    具体思路为:调用接口与服务器版本对比,当服务器版本号大于本地的,调用DownloadManager进行下载,之前也试过很多方法,但是兼容性都不是很好,还有一点要注意的是,在这里我并没有设置固定的下载路 ...

  6. Jquery和Javascript 实际项目中写法基础-ajax和json (3)

    一.什么是JSON数据? 一种轻量级的数据交换格式.实际中知道如何使用即可. 软件开发我认为就是一个会用,然后知其原理的过程. 例子如下: <!DOCTYPE html> <html ...

  7. MTP in Android详解

    MTP in Android详解 最近好长一段时间没有做笔记了,今天主要学习一下MTP相关的知识. MTP的全称是Media Transfer Protocol(媒体传输协议),它是微软公司提出的一套 ...

  8. travel for django

    参考博客:http://www.cnblogs.com/wupeiqi/articles/5237672.html 一:框架的本质: 最原始的框架:服务端一个简单的socket,接收客户端发出的请求, ...

  9. C++中的new与delete

    C++中对象数组创建时,主要注意的点有:虚函数和带参数的构造函数,当出现虚函数时,对象数组中如通过父对象指向子对象,因为需要做Slice,析构时会造成指针错误引发内存泄露.测试程序如下: class ...

  10. [转]恢复 git reset -hard 的误操作

    转帖:http://hi.baidu.com/configuration/item/97fddeea252818d0eb34c964 有时候使用Git工作得小心翼翼,特别是涉及到一些高级操作,例如 r ...