在Linux上安装Gearman及配置使用Gearman的PHP扩展环境
在Linux上安装Gearman及配置使用Gearman的PHP扩展环境。
先介绍安装 Gearman 。
1. 先安装依赖库
# yum install -y boost-devel gperf libevent-devel libuuid-devel
2. 下载 Gearman
下载:
# wget https://launchpad.net/gearmand/1.2/1.1.12/+download/gearmand-1.1.12.tar.gz
解压:
# tar -xzvf gearmand-1.1.12.tar.gz
3. 配置 Gearman
# cd gearmand-1.1.12
# pwd
/data/gearmand-1.1.12
# ./configure
...
checking for boostlib >= 1.39... configure: We could not detect the boost libraries (version 1.39 or higher). If you have a staged boost library (still not installed) please specify $BOOST_ROOT in your environment and do not give a PATH to --with-boost option. If you are sure you have boost installed, then check your version number looking in <boost/version.hpp>. See http://randspringer.de/boost for more documentation.
configure: error: could not find boost
如果出现上面错误,先检查当前安装的Boost版本是否 >= 1.39,如果版本低,就需要安装高版本的Boost。
如果已经安装了Boost,就先卸载再安装;如果版本 >= 1.39,也出现上面错误,也卸载再安装。
安装Boost:
# yum install boost
# yum install boost-devel
# yum install boost-doc
再执行配置:
# ./configure
4. 编译 Gearman
# pwd
/data/gearmand-1.1.12
# make
...
CXX util/gearmand_hostile_gearmand-daemon.o
CXX util/gearmand_hostile_gearmand-pidfile.o
CXX libtest/gearmand_hostile_gearmand-cpu.o
CXXLD gearmand/hostile_gearmand
/usr/bin/ld: cannot find -lmysqlclient
collect2: ld returned 1 exit status
make[1]: *** [gearmand/hostile_gearmand] Error 1
make[1]: Leaving directory `/data/backup/gearmand-1.1.12'
make: *** [all] Error 2
如果出现上面错误,就先查找 mysqlclient 库文件所在目录:
# find / -name *mysqlclient*
/usr/lib64/mysql/libmysqlclient.a
/usr/lib64/mysql/libmysqlclient_r.a
如上找到mysqlclient 库文件,就在/usr/lib/目录下建两个软链接:
# ln -s /usr/lib64/mysql/libmysqlclient.a /usr/lib/libmysqlclient.a
# ln -s /usr/lib64/mysql/libmysqlclient_r.a /usr/lib/libmysqlclient_r.a
如果没找到 mysqlclient 库文件,就需要安装 MySQL Client 了。
再执行编译:
# make
5. 安装 Gearman
# pwd
/data/gearmand-1.1.12
# make install
随意进入其他目录执行 gearman,检查安装是否成功:
# gearman
gearman Error in usage(No Functions were provided).
Client mode: gearman [options] [<data>]
Worker mode: gearman -w [options] [<command> [<args> ...]]
Common options to both client and worker modes.
-f <function> - Function name to use for jobs (can give many)
-h <host> - Job server host
-H - Print this help menu
-v - Print diagnostic information to stdout(false)
-p <port> - Job server port
-t <timeout> - Timeout in milliseconds
-i <pidfile> - Create a pidfile for the process
-S - Enable SSL connections
Client options:
-b - Run jobs in the background(false)
-I - Run jobs as high priority
-L - Run jobs as low priority
-n - Run one job per line(false)
-N - Same as -n, but strip off the newline(false)
-P - Prefix all output lines with functions names
-s - Send job without reading from standard input
-u <unique> - Unique key to use for job
Worker options:
-c <count> - Number of jobs for worker to run before exiting
-n - Send data packet for each line(false)
-N - Same as -n, but strip off the newline(false)
-w - Run in worker mode(false)
#
出现上面显示,说明安装 Gearman 成功了。
启动与停止 Gearman 服务:
1. 启动 Gearman
# gearmand -d --log-file=/data/gearman/logs/gearmand.log
log-file 参数指定日志文件。
2. 停止 Gearman
# gearadmin --shutdown
下面讲配置使用 Gearman 的 PHP 扩展环境。
1. 先安装PHP拓展环境
下载 gearman-1.1.2.tgz(注意,这个 gearman-1.1.2.tgz 与前面的 gearmand-1.1.12.tar.gz 不同):
# wget http://pecl.php.net/get/gearman-1.1.2.tgz
(下载列表地址:http://pecl.php.net/package/gearman)
# tar -zxvf gearman-1.1.2.tgz
配置:
# cd gearman-1.1.2
# phpize
如果出现“phpize: command not found”,就安装PHP :
# yum install php php-devel
然后再执行:
# phpize
Configuring for:
PHP Api Version: 20090626
Zend Module Api No: 20090626
Zend Extension Api No: 220090626
# ./configure
编译安装:
# make
# make install
Installing shared extensions: /usr/lib64/php/modules/
出现如上提示,说明安装成功, 在 /usr/lib64/php/modules/ 目录下有 gearman.so 文件。
2. 在php.ini文件中加入Gearman配置
在配置前,先编写个php程序测试下,程序很简单,就是打印 Gearman 版本。
# cd /data/test
# vi test.php
<?php
print gearman_version() . "\n";
?>
然后执行程序看什么结果:
# php test.php
PHP Fatal error: Call to undefined function gearman_version() in /data/test/test.php on line 2
调用了未定义的 gearman_version 函数。
下面加上配置后再运行程序看看。
先找到php.ini文件:
# find / -name php.ini
/etc/php.ini
# cd /etc
为把配置加入适当的位置,先查找文件中 extension 单词出现的位置:
# more php.ini | grep extension
; Directives are variables used to configure PHP or PHP extensions.
; dynamically loaded extension (either a PHP extension or a Zend extension),
; you may only use these constants *after* the line that loads the extension.
; leading '/'. You must also specify the file extension being used including
; Directory in which the loadable extensions (modules) reside.
; http://www.php.net/manual/en/ini.core.php#ini.extension-dir
; extension_dir = "./"
; If you wish to have an extension loaded automatically, use the following
; extension=modulename.extension
; extension=msql.so
; extension=/path/to/extension/msql.so
; If you only provide the name of the extension, PHP will look for it in its
; default extension directory.
; Note: packaged extension modules are now loaded via the .ini files
;sqlite3.extension_dir =
; Sets the directory name where SOAP extension will put cache files.
#
加入配置:
# vi php.ini
extension=gearman.so
位置:
再执行程序:
# php test.php
1.1.12
到此,使用 Gearman 的 PHP 扩展环境配置完成。
参考:
http://blog.csdn.net/clevercode/article/details/45718735
https://my.oschina.net/liucao/blog/755299
在Linux上安装Gearman及配置使用Gearman的PHP扩展环境相关推荐
- linux怎么安装java环境变量_如何简单的在linux上安装jdk并配置环境变量
这篇文章是为了给我一会自己安装的时候方便使用的,所以内容很简单,平时在wendows系统上安装很容易,但是换到linux系统上面就蒙圈了. 一.下载jdk文件 下载完成后你得到了 我们将这个文 ...
- Linux上安装Docker及配置阿里云镜像加速
Docker安装 Docker的基本组成 镜像(image) Docker 镜像(image)就是一个只读的模板.镜像可以用来创建Docker容器,一个镜像可以创建多个容器.就好比java中的类和对象 ...
- Linux上安装jdk并配置环境变量
个人资源与分享网站:http://xiaocaoshare.com/ 1.查看linux上根目录下所有文件 2.在usr下创建java目录,并在java目录创建jdk8目录 2.1 先切换到use目录 ...
- 阿里云linux上安装与配置Mysql
记录下在阿里云linux上安装与配置Mysql 环境:阿里云ECS服务器,系统为centos7.2 用户:root 文章目录 删除原来的数据库: 下载与安装MySQL: 关于登录MySQL: 配置远程 ...
- linux系统管理与服务器配置高志君_如何在 Linux 上安装、配置 NTP 服务器和客户端?...
你也许听说过这个词很多次或者你可能已经在使用它了.在这篇文章中我将会清晰的告诉你 NTP 服务器和客户端的安装. -- Magesh Maruthamuthu 你也许听说过这个词很多次或者你可能已经在 ...
- 如何在Red Hat Linux上安装和配置FreeIPA
目的 我们的目标是在Red Hat Enterprise Linux上安装和配置独立的FreeIPA服务器. 操作系统和软件版本 操作系统: Red Hat Enterprise Linux 7.5 ...
- 在红帽Linux上安装samba服务,如何在linux上安装配置samba服务器
如何在linux上安装配置samba服务器 更新时间:2019-10-29 22:40 最满意答案 1.首先需要登入安装了Linux系统的计算机,安装Samba.Fedora发行版一般使用yum工具安 ...
- Debian8 Linux上安装SSH服务器并配置sshd_config文件启用root ssh登录
Debian Linux上安装SSH服务器 安装SSH服务器debian Linux允许我们通过ssh协议登录debian服务器.SSH是从远程位置登录debian的首选方法,因为ssh协议通过Int ...
- linux上安装mysql,tomcat,jdk
Linux 上安装 1 安装jdk 检测是否安装了jdk 运行 java –version 若有 需要将其卸载 a) 查看安装哪些jdk rmp –qa |grep java b) ...
最新文章
- 炸了!一口气问了我18个JVM问题!
- Verilog 编写规范
- SQLite 使用(创、升、增、删、改、查)
- TensorFlow——加载和使用多个模型解决方案
- SAP Cloud for Customer客户主数据的地图集成
- 电脑上我的文档图标不见了怎么办
- 窗口限制文件上传格式
- js实现web贪吃蛇小游戏
- Android wifi信号强度显示流程
- go与python的前景_golang程序员前景怎么样?Python、Java、go语言的优势互比
- 转载:Max vs Maya
- 会员管理系统有哪些功能?
- G1D38-Evaluation Metrics
- 键盘查询方式的c语言编程,求助大佬简单的单片机键盘c语言编程问题
- linux查找最近新增的大文件
- HTML圣诞树代码(动态音效)
- nodejs(五)node引入核心模块fs
- vue 选中列表去重
- F4和L4的一个区别 (CCM)
- 微软 Win11 快捷键大全
热门文章
- error: C1083: 无法打开包括文件: “QtGui/QApplication”: No such file or directory
- 华为不上市真的是因为不缺钱么?
- python 写字机器人_中文英语是什么
- 初始电脑Path环境变量
- 我的勇敢萨满应该如何战斗?萨满国王的战术教学
- ad 活动目录 linux,Active Directory 活动目录
- gsm模块发中文短信
- unity中定时滑动公告板的实现及动态设置gridLayout的大小
- STL(list容器)
- java throwable_throwable和Exception的区别(详细一点)