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
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 ..
#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
/opt/modules/php/bin/phpize
./configure --with-php-config=/opt/modules/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
$worker= new GearmanWorker();
$worker->addServer();
$worker->addFunction("title", "title_function");
while ($worker->work());
function title_function($job)
{
return ucwords(strtolower($job->workload()));
}
?>
php worker.php &
#client.php
$client= new GearmanClient();
$client->addServer();
print $client->do("title", "AlL THE World's a sTagE");
print "\n";
?>
php client.php