docker容器里安装php的redis和swoole扩展

1、首先进入容器里

docker exec -it php sh(alpine系统用sh,centos系统用bash)

 2、使用pcel进行安装

2.1 安装pecl

alpine系统默认是没有pecl的,只能先安装pecl
curl -o go-pear.php http://pear.php.net/go-pear.phar
php go-pear.php
#一直回车就行
如果看到下面的一段话就是安装成功:
Run it without parameters to see the available actions, try'pear list'
to see what packages are installed, or'pear help'for help.
For more information about PEAR, see:
    http://pear.php.net/faq.php
    http://pear.php.net/manual/
Thanks for using go-pear!

2.2 安装php扩展

pecl search key-word    #用于查找扩展
pecl install key-word   #用于安装扩展

查询相关扩展 

/var/www/html # pecl search redis
Retrieving data...0%
Matched packages, channel pecl.php.net:
=======================================
Package Stable/(Latest)  Local
redis   5.1.0RC1 (alpha)       PHP extension for interfacing with Redis

/var/www/html # pecl search swoole
Retrieving data...0%
.Matched packages, channel pecl.php.net:
=======================================
Package          Stable/(Latest) Local
swoole           4.4.8 (stable)        Event-driven asynchronous and concurrent networking engine with high performance for PHP.
swoole_serialize 0.1.1 (beta)          the fastest and smallest serialize fucntion bound for php7

安装相关扩展

1)如果出现以下错误,说明没有安装autoconf

安装autoconf(基于alpine安装命令)

apk add --no-cache -U autoconf(基于alpine系统)
yum -y install autoconf(基于centos系统)
/var/www/html # apk add --no-cache -U autoconf
fetch http://dl-cdn.alpinelinux.org/alpine/v3.10/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.10/community/x86_64/APKINDEX.tar.gz
(1/4) Installing m4 (1.4.18-r1)
(2/4) Installing libbz2 (1.0.6-r7)
(3/4) Installing perl (5.28.2-r1)
(4/4) Installing autoconf (2.69-r2)
Executing busybox-1.30.1-r2.trigger
OK: 59 MiB in 34 packages

再次安装redis,出现以下错误,说明需要安装gcc

apk add --no-cache -U gcc(基于alpine系统)
yum -y install gcc(基于centos系统)

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值