Ubuntu 12.04 安裝 gearman 以及php擴充安裝指令碼

來源:互聯網
上載者:User

標籤:gearman php shell


#!/usr/bash#create by lhb#date 2014-05-07#desc install gearman and php extension for Ubuntu 12.04.4 LTS  PHP 5.5apt-get update#安裝依賴庫apt-get install libboost-all-dev gperf libevent1-dev libcloog-ppl0mkdir -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.gztar zxvf gearmand-1.1.8.tar.gzcd gearmand-1.1.8/./configuremakemake installcd ..apt-get install gearman-job-serverservice gearman-job-server startps -ef |grep gearman#安裝php5-fpmapt-get install php5-fpm php-cli php5-cli php5-dev#下載gearman的php擴充庫wget http://pecl.php.net/get/gearman-1.1.2.tgztar zxvf gearman-1.1.2.tgzcd gearman-1.1.2/phpizewhereis php-config./configure --with-php-config=/usr/bin/php-configmakemake 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.inifor target_path in /etc/php5/cli/conf.d/ /etc/php5/fpm/conf.d/ ; do        cd $target_path && ln -s ../../mods-available/gearman.ini gearman.inidoneservice php5-fpm restart#查看擴充是否安裝成功php --info | grep "gearman"查看是否啟動ps auxw | grep [g]earmandlsof -i tcp:4730


650) this.width=650;" src="http://s3.51cto.com/wyfs02/M00/26/32/wKiom1NqEPHjPaXMAACsyb68Z8U836.jpg" title="15.jpg" alt="wKiom1NqEPHjPaXMAACsyb68Z8U836.jpg" />


650) this.width=650;" src="http://s3.51cto.com/wyfs02/M00/26/32/wKioL1NqEC_xrtLyAAH1RaJaL2k155.jpg" title="13.jpg" alt="wKioL1NqEC_xrtLyAAH1RaJaL2k155.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";?>


測試結果:

650) this.width=650;" src="http://s3.51cto.com/wyfs02/M02/26/32/wKioL1NqD4XC-lCeAABuCL821z8142.jpg" title="12.jpg" alt="wKioL1NqD4XC-lCeAABuCL821z8142.jpg" />


本文出自 “宅鳥樂園” 部落格,轉載請與作者聯絡!

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.