Linux安装gearman

安装Gearman

  1. 安装前的准备

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

    cd /root
    wget https://github.com/gearman/gearmand/releases/download/1.1.17/gearmand-1.1.17.tar.gz
    tar -zxvf gearmand-1.1.17.tar.gz
    cd gearmand-1.1.17
    ./configure \
    --prefix=/usr/local/gearman/ \
    --disable-libpq \
    --disable-hiredis \
    --disable-libdrizzle \
    --disable-silent-rules \
    --disable-libtool-lock \
    --disable-libmemcached \
    --disable-option-checking \
    --disable-libtokyocabinet \
    --disable-dependency-tracking
    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
    
    # 修改文件权限为只有root用户可以编辑该文件
    chown -R root:root /etc/systemd/system/gearman.service
    chmod -R 644 /etc/systemd/system/gearman.service
    
    # 更新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/wcgallego/pecl-gearman/archive/gearman-2.0.3.tar.gz
    tar -zxvf gearman-2.0.3.tar.gz
    cd pecl-gearman-gearman-2.0.3
    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修订: 2020-03-26 14:23:53

results matching ""

    No results matching ""