Linux安装gearman

  1. 作者QQ:67065435 QQ群:821635552

安装Gearman

  1. 安装前的准备

    # CentOS
    yum install \
    vim \
    git \
    gcc \
    gcc-c++ \
    wget \
    make \
    gperf \
    hiredis \
    automake \
    autoconf \
    boost-devel \
    libuuid-devel \
    libevent-devel \
    -y
    
  2. 安装gearmand 源码地址 源码下载

    cd /root
    
    wget https://github.com/gearman/gearmand/releases/download/1.1.19.1/gearmand-1.1.19.1.tar.gz
    tar -zxvf gearmand-1.1.19.1.tar.gz
    cd gearmand-1.1.19.1
    
    ./configure \
    --prefix=/usr/local/gearman
    
    make
    make install
    
  3. 创建gearman用户

    useradd -s /sbin/nologin -M gearman
    
    mkdir /usr/local/gearman/var/
    mkdir /usr/local/gearman/var/log/
    chown -R gearman:gearman /usr/local/gearman/
    
  4. 启动gearman并设置开机启动

    # 进入单元文件目录
    cd /etc/systemd/system
    
    # 创建redis单元文件,格式为: [单元文件名].[单元文件类型]
    vim gearman.service
    
    [Unit]
    Description=Start gearman on boot.
    After=default.target network.target
    
    [Service]
    User=gearman
    Group=gearman
    Type=forking
    ExecStart=/usr/local/gearman/sbin/gearmand --log-file=/usr/local/gearman/var/log/gearmand.log --pid-file=/usr/local/gearman/var/log/gearmand.pid -d
    PrivateTmp=false
    Restart=always
    
    [Install]
    WantedBy=multi-user.target
    
    ESC
    :wq
    
    # 注意事项:如果要做持久化,将【ExecStart】修改如下
    
    ExecStart=/usr/local/gearman/sbin/gearmand \
    --log-file=/usr/local/gearman/var/log/gearmand.log \
    --pid-file=/usr/local/gearman/var/log/gearmand.pid \
    -d \
    redis \
    --redis-server 127.0.0.1 \
    --redis-port 6379 \
    --redis-password '' \
    --redis-prefix prefix
    
    # 更新systemd
    systemctl daemon-reload
    systemctl enable gearman
    systemctl start gearman
    

安装php扩展

  1. 安装php的gearman扩展 Gearman地址 Gearman下载

    yum install libgearman-devel -y
    cd ~
    wget https://github.com/php/pecl-networking-gearman/archive/gearman-2.0.6.tar.gz
    tar -zxvf gearman-2.0.6.tar.gz
    cd pecl-networking-gearman-gearman-2.0.6
    phpize
    ./configure
    make
    make install
    
  2. 修改php.ini

    vim /usr/local/php7/lib/php.ini
    
    extension=gearman.so
    
    ESC
    :wq
    
Copyright © 豆包嘿嘿~ 2012-∞ 冀ICP备17033181号 all right reserved,powered by Gitbook修订: 2012-12-31 12:00:00

results matching ""

    No results matching ""