gearman php扩展 windows,Ubuntu 12.04 安装 gearman 以及php扩展安装脚本

#!/usr/bash

#create by lhb

#date 2014-05-07

#desc install gearman and php extension for Ubuntu 12.04.4 LTS PHP 5.5

apt-get update

#安装依赖库

apt-get install libboost-all-dev gperf libevent1-dev libcloog-ppl0

mkdir -pv /home/lhb/software && cd /home/lhb/software

#下载gearman包

wget https://launchpad.net/gearmand/1.2/1.1.8/+download/gearmand-1.1.8.tar.gz

tar zxvf gearmand-1.1.8.tar.gz

cd gearmand-1.1.8/

./configure

make

make install

cd ..

apt-get install gearman-job-server

service gearman-job-server start

ps -ef |grep gearman

#安装php5-fpm

apt-get install php5-fpm php-cli php5-cli php5-dev

#下载gearman的php扩展库

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

tar zxvf gearman-1.1.2.tgz

cd gearman-1.1.2/

phpize

whereis php-config

./configure --with-php-config=/usr/bin/php-config

make

make install

#加入到php.ini配置

echo "extension=gearman.so" > /etc/php5/mods-available/gearman.ini

#cd /etc/php5/cli/conf.d/ && ln -s ../../mods-available/gearman.ini gearman.ini

#cd /etc/php5/fpm/conf.d/ && ln -s ../../mods-available/gearman.ini gearman.ini

for target_path in /etc/php5/cli/conf.d/ /etc/php5/fpm/conf.d/ ; do

cd $target_path && ln -s ../../mods-available/gearman.ini gearman.ini

done

service php5-fpm restart

#查看扩展是否安装成功

php --info | grep "gearman"

查看是否启动

ps auxw | grep [g]earmand

lsof -i tcp:4730

101765_0.jpg

101765_1.jpg

worker.php<?php

$worker= new GearmanWorker();

$worker->addServer();

$worker->addFunction("lhb", "lhb_test");

while ($worker->work());

function lhb_test($job)

{

return strtoupper($job->workload());

}

?>

client.php<?php

$client= new GearmanClient();

$client->addServer();

print $client->do("lhb", "this is a test by lhb");

print "n";

?>

测试结果:

101765_2.jpg

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值