http://gearman.org/
http://pecl.php.net/package/gearmanCentOS 2.6.32
可以先直接安装 Gearmand, 看缺什么再选择下面的进行安装!
yum install gcc-c++
wget https://github.com/boostorg/build/archive/2014.10.tar.gz ./bootstrap.sh ./b2 install
yum install gperf.x86_64
yum -y install libevent libevent-devel
http://sourceforge.net/projects/libuuid/files/latest/download wget http://downloads.sourceforge.net/project/libuuid/libuuid-1.0.3.tar.gz tar zxvf libuuid-1.0.3.tar.gz ./configure make & make install
wget https://launchpad.net/gearmand/1.2/1.1.12/+download/gearmand-1.1.12.tar.gz tar zxvf gearmand-1.1.12.tar.gz cd gearmand-1.1.12 ./configure make & make install
wget http://pecl.php.net/get/gearman-1.1.2.tgz phpize ./configure make & make install
gearmand -d [root@localhost www]# ps -ef | grep gearmand root 19109 1 0 01:06 ? 00:00:00 /usr/local/sbin/gearmand -d root 22185 3160 0 03:19 pts/1 00:00:00 grep gearmand
[worker] [root@localhost www] gearman -w -f wc -- wc -l [client] [root@localhost www] gearman -f wc < /etc/passwd 26
[worker.php]
<?php $worker = new GearmanWorker(); $worker->addServer(); $worker->addFunction("strtoupper", "my_func"); while ($worker->work()); function my_func($job) { return strtoupper($job->workload()); }
[client.php]
<?php
$client = new GearmanClient(); $client->addServer(); $string = $client->doNormal("strtoupper", "hello world"); echo $string;
[执行]
[root@localhost www]php worker.php [root@localhost www]php client.php HELLO WORLD
Done!