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系统)