linux下 gearman+php的使用
2016-06-03 10:06
435 查看
gearman原理
1:liunx下安装gearman
2:启动gearmand
3:查看php的扩展是否有gearman的扩展
4:demo演示
1:liunx下安装gearman
yum install gearmand libgearman libgearman-devel -y
2:启动gearmand
gearmand -d #-d 是后台运行 可以--help看下其他的配置选项
3:查看php的扩展是否有gearman的扩展
php -m | grep gearman #如果有的话,最好了 #没有也没关系,装上它 (学习一下怎么用命令去装扩展,不建议用tar包一点点去装) 学习网址:http://php.net/manual/zh/install.pecl.pear.php 我自己使用的是yum来安装的 yum install php-gearman 最标准的应该安装官方的pecl来做
4:demo演示
client.php <?php // Reverse Client Code $client = new GearmanClient(); $client->addServer(); print $client->do("reverse", "0123456789"); echo "\n";
work.php <?php // Reverse Worker Code $worker = new GearmanWorker(); $worker->addServer(); $worker->addFunction("reverse", function ($job) { echo "内容" . $str = $job->workload(); return strrev($str); }); while ($worker->work());
相关文章推荐
- linux命令详解——eval
- linux命令详解——eval
- 初识CentOS服务命令大全
- CentOS的启动方式和语言设置
- [备忘]TensorFlow在CentOS里的配置
- Linux下printf函数显示不同的颜色
- Centos使用ntpdate自动更新系统时间
- linux JAVA JDK环境配置
- linux上搭建svn版本库
- Linux参数调整
- linux下收集系统全面信息(基于sosreport以及supportconfig)
- Linux常用命令及工具
- Centos 修改时间地区及NTP同步北京时间
- Linux下 LVS NAT模型的配置演示
- 监控Linux性能的18个命令行工具
- linux系统内核升级实例
- Android Linux内核驱动程序(基于goldfish-3.10内核)
- linux基本命令的使用(最基本的)
- YUM Q n A
- UNIX 环境高级编程(二)—— linux共享库,/etc/ld.so.conf 及 ld.so.conf.d/libc.conf