centos安装gearmand及php扩展

#install check  
yum -y install yum-fastestmirror  
yum -y install patch make gcc gcc-c++ gcc-g77  
yum -y install libevent libevent-devel  
yum -y install php-devel
wget http://www.monkey.org/~provos/libevent-1.4.12-stable.tar.gz
tar -zxvf libevent-1.4.12-stable.tar.gz 
cd libevent-1.4.12-stable
./configure --prefix=/usr
make && make install
/sbin/ldconfig

wget -c http://launchpadlibrarian.net/51244438/gearmand-0.14.tar.gz  
tar zxvf gearmand-0.14.tar.gz  
cd gearmand-0.14  
./configure  
make && make install  
/sbin/ldconfig  
cd ..  
/*
  gearmand很有可能安装不成功,现在发现一个rpm的源:
  wget http://mirrors.sohu.com/fedora-epel/5/x86_64/epel-release-5-4.noarch.rpm
  sudo rpm -Uvh epel-release-5-4.noarch.rpm
  sudo yum install gearmand
*/
/*
  在安装的过程中也可能遇到一些问题,比如:undefined reference to `gearman_server_queue_libmemcached_conf'
  删除gearmand-0.14/config.h文件63行的代码:#define HAVE_LIBMEMCACHED 1
  然后再make && make install
*/
#install php extension  wget -c http://pecl.php.net/get/gearman-0.8.0.tgz  tar zxvf gearman-0.8.0.tgz 
cd gearman
-0.8.0

phpize

./configure --with-php-config=/usr/local/php/bin/php-config --with-gearman
make
make install
cd
../

#edit php.ini #extension = gearman.so #start server
/usr/local/sbin/gearmand -p 4730 -u root -d
#php demo worker.php  
<?php  
  $worker= new GearmanWorker();  
  $worker->addServer();  
  $worker->addFunction("title", "title_function");  
  while ($worker->work());  
     
  function title_function($job)  
  {  
    return ucwords(strtolower($job->workload()));  
  }  
?>  
  
/usr/local/php/bin/php worker.php &  
  
#client.php  
<?php  
  $client= new GearmanClient();  
  $client->addServer();  
  print $client->do("title", "AlL THE World's a sTagE");  
  print "\n";  
?>
/usr/local/php/bin/php client.php
原文地址:https://www.cnblogs.com/liqiu/p/2736761.html