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

简介:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/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


wKiom1NqEPHjPaXMAACsyb68Z8U836.jpg


wKioL1NqEC_xrtLyAAH1RaJaL2k155.jpg


worker.php

1
2
3
4
5
6
7
8
9
10
<?php
   $worker new  GearmanWorker();
   $worker ->addServer();
   $worker ->addFunction( "lhb" "lhb_test" );
   while  ( $worker ->work());
   function  lhb_test( $job )
   {
     return  strtoupper ( $job ->workload());
   }
?>


client.php

1
2
3
4
5
6
<?php
   $client new  GearmanClient();
   $client ->addServer();
   print  $client -> do ( "lhb" "this is a test by lhb" );
   print  "\n" ;
?>


测试结果:

wKioL1NqD4XC-lCeAABuCL821z8142.jpg


本文转自birdinroom 51CTO博客,原文链接:http://blog.51cto.com/birdinroom/1408075,如需转载请自行联系原作者

相关文章
|
3天前
|
Ubuntu Linux Python
Linux(15)Ubuntu安装ninja构建工具
Linux(15)Ubuntu安装ninja构建工具
14 0
|
29天前
|
Ubuntu NoSQL 关系型数据库
Ubuntu系统下安装常用软件
Ubuntu系统下安装常用软件
58 0
Ubuntu系统下安装常用软件
|
1月前
|
Ubuntu Linux C语言
Ubuntu下安装vscode,并解决终端打不开vscode的问题
Ubuntu下安装vscode,并解决终端打不开vscode的问题
151 0
|
30天前
|
Ubuntu 关系型数据库 MySQL
Ubuntu 中apt 安装MySQL数据库
Ubuntu 中apt 安装MySQL数据库
69 0
|
3天前
|
Ubuntu Linux 数据安全/隐私保护
Linux(7)Ubuntu20.04 arm64安装Docker
Linux(7)Ubuntu20.04 arm64安装Docker
15 0
|
4天前
|
存储 Ubuntu Docker
如何在 Ubuntu 上安装 Docker?
【4月更文挑战第17天】
42 8
如何在 Ubuntu 上安装 Docker?
|
7天前
|
Ubuntu Docker 索引
ubuntu 20.04 安装docker教程和安装中遇到的问题解决方案(超详细 附加图文教程)
ubuntu 20.04 安装docker教程和安装中遇到的问题解决方案(超详细 附加图文教程)
30 0
|
9天前
|
Ubuntu 数据安全/隐私保护
在UBUNTU虚拟机上安装R软件包
在UBUNTU虚拟机上安装R软件包
13 0
|
9天前
|
存储 编解码 Ubuntu
0-零基础安装ubuntu(超详细安装步骤)
0-零基础安装ubuntu(超详细安装步骤)
|
10天前
|
Ubuntu Linux 定位技术
手把手教你优雅的安装虚拟机 Ubuntu —— 图文并茂
手把手教你优雅的安装虚拟机 Ubuntu —— 图文并茂