[转]编译安装libevent,memcache,以及php的memcached扩展
一 安装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://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扩展的更多相关文章
- 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 ...
- centOs编译安装php7.2支持微擎php扩展
发现yum安装许多坑 于是只好编译安装 第一步得到镜像地址 在 https://www.php.net/downloads.php 有的地址比较慢,需要耐心等待 cd /usr/lo ...
- yum 安装apache php 使php支持memcached扩展
在公司上新项目的时候,无论生产环境还是测试环境,都会让运维安装php 环境(lamp/lnmp),并让php支持memcached 的扩展.这里搭建php环境其实主要就是搭建apache 和php.m ...
- Linux下编译安装Memcache
需要gcc,make,cmake,autoconf,libtool等工具,联网后,yum install -y gcc,make,cmake,autoconf,libtool 编译安装libevent ...
- CentOS6.3编译安装Memcached
要用到如下源码包: /usr/local/src/memcached/libevent-2.0.21-stable.tar.gz /usr/local/src/memcached/memcached- ...
- centos7编译安装pgbouncer
1.下载pgbouncer程序包和libevent依赖包 wget https://github.com/libevent/libevent/releases/download/release-2.1 ...
- ffmpeg源码编译安装(Compile ffmpeg with source) Part 2 : 扩展安装
在Ubuntu,Debian,Mint上编译ffmpeg 本文主要为在Ubuntu,Debian和Mint上编译安装ffmpeg和库文件以及一些扩展的编解码器.当然这与从源中安装无关. 请首先看一下通 ...
- 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 ...
- Linux下memcache编译安装与基本使用
memcache是一套分布式的高速缓存系统,特点为key-value 存储 一.在 linux 编译安装memcache.redis等,需要 gcc,make,cmake,autoconf,libto ...
随机推荐
- html5 请求的URL转成 OC可用属性字符串显示
NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:helpUrlStr]]; NSString *string = [ ...
- 关于zero_interconnect_delay_mode和nonzero_interconnect_delay_mode的区别
在执行report_qor命令时,需要注意这样一个问题,对于Reg_2_Reg路径,在worst scene情况下,nonzero模型要比zero模型报出的结果差,但在best scene情况下,却要 ...
- 向peersim开火!P2P开火!(安装和样例运行)
根据导师的要求,这次的任务是要模拟一个类似BT网络的P2P网络,并实现一些算法,查了些资料,都说NS2对于P2P网络的模拟和支持都不好,基本没有模板可以用,而且效率很低,只能模拟几万个节点左右,看到挺 ...
- HDU 1237
http://acm.hdu.edu.cn/showproblem.php?pid=1237 表达式计算,方法是中缀转后缀,再计算.中间处理用栈操作 讲解看http://blog.csdn.net/a ...
- win7系统下的FTP配置
2016-07-12 工作中需要在win7操作系统下配置FTP,遇到许多问题,所以记录下来方便以后解决问题. FTP是文件传输协议的简称.用于Internet上的控制文件的双向传输.同时,它也是一个应 ...
- OpenStack虚拟机DHCP获取不到IP地址排查
版本:OpenStack Liberty Neutron DVR 现象: 1.在虚拟机内部不停地dhclient 2.在虚拟机所属的计算节点的物理网卡上抓包,发现该虚拟机发出的dhcp广播包 3.在虚 ...
- 手把手教你配置UltraEdit对Oracle的PLSQL着色
http://hi.baidu.com/kingbridge/blog/item/94e225ad5fad4b194b36d60d.html UltraEdit-32 12.1版本配置默认文件显示 ...
- POJ 1014 Dividing
Dividing Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 66032 Accepted: 17182 Descriptio ...
- android aidl 进程间通信需要注意的地方(android.os.TransactionTooLargeException)
转自:http://blog.sina.com.cn/s/blog_4e1e357d0102wau9.html 1.bus工程实现通过service实现aidl实体类 2.actor工程通过发起bin ...
- 2016 、12 、11<本周>
翻了翻记录 想把上周没搞出来的1159和day2T2搞出来.