Centos7安装gearman和php扩展
标签(空格分隔): php,linux
gearman所需要的依赖
yum install \
vim \
git \
gcc \
gcc-c++ \
wget \
make \
gperf \
automake \
autoconf \
boost-devel \
libuuid-devel \
libevent-devel \
-y \
安装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
创建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/
启动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
安装php扩展
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
修改php.ini
vim /usr/local/gearman/php-7.0.13/lib/php.ini
extension=gearman.so
ESC