一、安装准备
wget https://launchpad.net/gearmand/1.2/1.1.2/+download/gearmand-1.1.2.tar.gz
接下来下载依赖库Boost C++ 库,因为boost库版本必须大于1.39所以我们下载boost_1_49_0.tar.gz
地址:http://sourceforge.net/projects/boost/files/boost/1.49.0/
然后用yum安装其他依赖库
yum install uuidd libevent libevent-devel gcc44 gcc44-c++ libstdc++44-devel
注意如果不安装gcc44相关库在make && make install的时候会报错误
tr1/cinttypes: No such file or directory
二、安装
编译安装Boost
tar xvzf boost_1_49_0.tar.gz
cd boost_1_49_0
./bootstrap.sh
./b2 install
(安装编译过程大概需要20分钟)
编译安装Gearman
tar xvzf gearmand-1.1.2.tar.gz
cd gearmand-1.1.2
./configure --prefix=/home/server/gearmand-1.1.2
make && make install
这步出现./libgearman-1.0/gearman.h:53:27: error: tr1/cinttypes: No such file or directory错误,可以推断是gcc编译器的问题,执行命令:
yum install gcc44 gcc44-c++ libstdc++44-devel -y
然后在环境变量里加入:
export CC=/usr/bin/gcc44 or export CC=/usr/bin/gcc
export CXX=/usr/bin/g++44
三、安装php gearman扩展(和gearmand不同服务器)
1. 安装依赖库
yum install gcc44 gcc-c++
export CC="gcc44"
export CXX="g++44"
2. 下载libgearman(c) 否则会报error: Please install libgearman错误
wget http://launchpad.net/gearmand/trunk/0.29/+download/gearmand-0.29.tar.gz
tar xvzf gearmand-0.29.tar.gz
cd gearmand-0.29
./configure --prefix=/usr/local/gearmand-1.1.2
make && make install
3. 下载gearman php 扩展库
wget http://pecl.php.net/get/gearman-1.1.0.tgz
tar xvzf gearman-1.1.0.tgz
cd gearman-1.1.0
phpize
./configure --with-php-config=/usr/local/php5.2.17/bin/php-config --with-gearman=/use/local/gearmand-1.1.2/
在php.ini中添加extension=gearman.so
-------------------
BUG说明或者说5.2安装gearman-1.1.0.tgz说明
http://pecl.php.net/package/gearman/1.1.0页面中gearman 1.1.0安装包描述信息说只要
Dependencies for release 1.1.0
PHP Version: PHP version 6.0.0 or older
PHP Version: PHP 5.1.0 or newer
PEAR Package: PEAR Installer 1.4.0b1 or newer
我用php5.2.17安装的时候发现出现E_DEPRECATED未定义错误
我查了php5.3的更新列表,这个错误等级变量是5.3更新的所以5.2的php装不上这个扩展
有两种办法解决这个问题
1. 升级php到5.3版本
2.替换php_gearman.c中的E_DEPRECATED为其他错误等级变量,比如E_ERROR
以上修改在centos5.8 php5.2.17环境下编译成功