gearman的安装

1 .安装gearmand服务

官网
访问官网:https://launchpad.net/gearmand

右侧下载

# wget https://launchpad.net/gearmand/1.2/1.1.12/+download/gearmand-1.1.12.tar.gz
# tar -zxvf gearmand-1.1.12.tar.gz
# cd gearmand-1.1.12
# ./configure
# make && make install


2. 安装gearman扩展

访问官网:https://pecl.php.net/
找到 gearman 扩展地址 最新稳定版本
下载地址

# wget https://pecl.php.net//get/gearman-1.1.2.tgz

# tar -zxvf gearman-1.1.2.tgz   #这里需要解压到你的PHP源代码的ext目录下
# /usr/local/php/bin/phpize     #生成configure文件
# ./configure --with-php-config=/usr/local/php/bin/php-config
# make
# make test
# make install

然后去php.ini 中添加

extensio=gearman.so

执行

php -m | grep 'gearman' 


就看到已经加载成功了


【错误1】
configure: error: Please install libgearman
解决:
(扩展 的config.m4文件告诉UNIX构建系统您的扩展支持哪些配置选项,您需要哪些外部库和包含,以及将哪些源文件作为其一部分进行编译)
首先我们查看错误来源 config.m4 中有段话

for i in $PHP_GEARMAN /usr/local /usr /opt/local; do
    if test -r $i/include/libgearman/gearman.h; then
      GEARMAN_LIB_DIR=$i/lib
      GEARMAN_INC_DIR=$i/include
      AC_MSG_RESULT([found in $i])
      break
    fi
  done

  if test -z "$GEARMAN_LIB_DIR" -o -z "$GEARMAN_INC_DIR"; then
     AC_MSG_RESULT([not found])
     AC_MSG_ERROR([Please install libgearman])
  fi

是因为 gearman.h 找不到就会一直报此错,所以
请确保你安装PHP扩展之前,已经安装好了gearmand服务,否则会一直报错
yum -y install libgearman
这句无法生成 gearman.h


【错误2】
make test
+-----------------------------------------------------------+
|                       ! ERROR !                           |
| The test-suite requires that proc_open() is available.    |
| Please check if you disabled it in php.ini.               |
+-----------------------------------------------------------+
需要php.ini 开启俩个函数
proc_open 
shell_exec


【错误3】
Warning: PHP Startup: Invalid library (maybe not a PHP library) 'gearman.so' in Unknown on line 0
解决:
请升级你的扩展版本,官网的扩展版本 http://gearman.org/download/
提供的版本是 1.0.2,我的PHP版本是5.6.3 编译好扩展后,加入php.ini 一直会报这个错误
去PHP扩展官网中查找 https://pecl.php.net/
下了新的版本  https://pecl.php.net/get/gearman-1.1.2.tgz  重新编译就好了

猜你喜欢

转载自blog.csdn.net/wujiangwei567/article/details/81501607