CentOS7.X下安装Gearman-1.1.17及其PHP-7.X扩展

CentOS下安装Gearman及其PHP扩展

  1. 本文由原官方文档翻译而来

安装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
    PIDFile=/usr/local/gearman/var/log/gearmand.pid
    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
    ExecReload=/bin/kill -s HUP $MAINPID
    ExecStop=/bin/kill -s QUIT $MAINPID
    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
  5. 领支付宝红包支持作者

    CentOS7.X下安装Gearman-1.1.17及其PHP-7.X扩展

    安装php扩展

  6. 安装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
  7. 修改php.ini

    vim /usr/local/gearman/php-7.0.13/lib/php.ini
    
    extension=gearman.so
    
    ESC
上一篇:CentOS7.X更新gcc到5.3.0


下一篇:CentOS7.X安装FastDFS-5.10