feat: 解决 PHP 5.6 安装 redis 失败的问题

This commit is contained in:
zhengkunwang223 2023-11-06 17:31:07 +08:00
parent 970ca3d23e
commit f858355a3b
2 changed files with 60 additions and 107 deletions

View File

@ -27,9 +27,9 @@ export EXTENSIONS=",${PHP_EXTENSIONS},"
# specific version. # specific version.
# #
# For example, to check if current php is greater than or # For example, to check if current php is greater than or
# equal to PHP 7.0: # equal to PHP 5.6:
# #
# isPhpVersionGreaterOrEqual 7 0 # isPhpVersionGreaterOrEqual 5 6
# #
# Param 1: Specific PHP Major version # Param 1: Specific PHP Major version
# Param 2: Specific PHP Minor version # Param 2: Specific PHP Minor version
@ -60,19 +60,27 @@ isPhpVersionGreaterOrEqual()
installExtensionFromTgz() installExtensionFromTgz()
{ {
tgzName=$1 tgzName=$1
para1= result=""
extensionName="${tgzName%%-*}" extensionName="${tgzName%%-*}"
shift 1
if [ $2 ]; then result=$@
para1=$2
fi
mkdir ${extensionName} mkdir ${extensionName}
tar -xf ${tgzName}.tgz -C ${extensionName} --strip-components=1 tar -xf ${tgzName}.tgz -C ${extensionName} --strip-components=1
( cd ${extensionName} && phpize && ./configure ${para1} && make ${MC} && make install ) ( cd ${extensionName} && phpize && ./configure ${result} && make ${MC} && make install )
docker-php-ext-enable ${extensionName} docker-php-ext-enable ${extensionName}
} }
if [[ -z "${EXTENSIONS##*,ioncube_loader,*}" ]]; then
echo "---------- Install ioncube_loader ----------"
install-php-extensions ioncube_loader
fi
if [[ -z "${EXTENSIONS##*,imagick,*}" ]]; then
echo "---------- Install imagick ----------"
install-php-extensions imagick
fi
if [[ -z "${EXTENSIONS##*,pdo_mysql,*}" ]]; then if [[ -z "${EXTENSIONS##*,pdo_mysql,*}" ]]; then
echo "---------- Install pdo_mysql ----------" echo "---------- Install pdo_mysql ----------"
@ -209,16 +217,6 @@ if [[ -z "${EXTENSIONS##*,hprose,*}" ]]; then
docker-php-ext-enable hprose docker-php-ext-enable hprose
fi fi
if [[ -z "${EXTENSIONS##*,ioncube_loader,*}" ]]; then
echo "---------- Install ioncube_loader ----------"
install-php-extensions ioncube_loader
fi
if [[ -z "${EXTENSIONS##*,imagick,*}" ]]; then
echo "---------- Install imagick ----------"
install-php-extensions imagick
fi
if [[ -z "${EXTENSIONS##*,gd,*}" ]]; then if [[ -z "${EXTENSIONS##*,gd,*}" ]]; then
echo "---------- Install gd ----------" echo "---------- Install gd ----------"
isPhpVersionGreaterOrEqual 7 4 isPhpVersionGreaterOrEqual 7 4
@ -390,47 +388,47 @@ fi
if [[ -z "${EXTENSIONS##*,ssh2,*}" ]]; then if [[ -z "${EXTENSIONS##*,ssh2,*}" ]]; then
isPhpVersionGreaterOrEqual 7 0 isPhpVersionGreaterOrEqual 5 6
if [[ "$?" = "1" ]]; then if [[ "$?" = "1" ]]; then
echo "---------- Install ssh2 ----------" echo "---------- Install ssh2 ----------"
printf "\n" | apk add libssh2-dev printf "\n" | apk add libssh2-dev
pecl install ssh2-1.1.2 pecl install ssh2-1.1.2
docker-php-ext-enable ssh2 docker-php-ext-enable ssh2
else else
echo "ssh2 requires PHP >= 7.0.0, installed version is ${PHP_VERSION}" echo "ssh2 requires PHP >= 5.6.0, installed version is ${PHP_VERSION}"
fi fi
fi fi
if [[ -z "${EXTENSIONS##*,protobuf,*}" ]]; then if [[ -z "${EXTENSIONS##*,protobuf,*}" ]]; then
isPhpVersionGreaterOrEqual 7 0 isPhpVersionGreaterOrEqual 5 6
if [[ "$?" = "1" ]]; then if [[ "$?" = "1" ]]; then
echo "---------- Install protobuf ----------" echo "---------- Install protobuf ----------"
printf "\n" | pecl install protobuf printf "\n" | pecl install protobuf
docker-php-ext-enable protobuf docker-php-ext-enable protobuf
else else
echo "yar requires PHP >= 7.0.0, installed version is ${PHP_VERSION}" echo "yar requires PHP >= 5.6.0, installed version is ${PHP_VERSION}"
fi fi
fi fi
if [[ -z "${EXTENSIONS##*,yac,*}" ]]; then if [[ -z "${EXTENSIONS##*,yac,*}" ]]; then
isPhpVersionGreaterOrEqual 7 0 isPhpVersionGreaterOrEqual 5 6
if [[ "$?" = "1" ]]; then if [[ "$?" = "1" ]]; then
echo "---------- Install yac ----------" echo "---------- Install yac ----------"
printf "\n" | pecl install yac-2.0.2 printf "\n" | pecl install yac-2.0.2
docker-php-ext-enable yac docker-php-ext-enable yac
else else
echo "yar requires PHP >= 7.0.0, installed version is ${PHP_VERSION}" echo "yar requires PHP >= 5.6.0, installed version is ${PHP_VERSION}"
fi fi
fi fi
if [[ -z "${EXTENSIONS##*,yar,*}" ]]; then if [[ -z "${EXTENSIONS##*,yar,*}" ]]; then
isPhpVersionGreaterOrEqual 7 0 isPhpVersionGreaterOrEqual 5 6
if [[ "$?" = "1" ]]; then if [[ "$?" = "1" ]]; then
echo "---------- Install yar ----------" echo "---------- Install yar ----------"
printf "\n" | pecl install yar printf "\n" | pecl install yar
docker-php-ext-enable yar docker-php-ext-enable yar
else else
echo "yar requires PHP >= 7.0.0, installed version is ${PHP_VERSION}" echo "yar requires PHP >= 5.6.0, installed version is ${PHP_VERSION}"
fi fi
fi fi
@ -438,13 +436,13 @@ fi
if [[ -z "${EXTENSIONS##*,yaconf,*}" ]]; then if [[ -z "${EXTENSIONS##*,yaconf,*}" ]]; then
isPhpVersionGreaterOrEqual 7 0 isPhpVersionGreaterOrEqual 5 6
if [[ "$?" = "1" ]]; then if [[ "$?" = "1" ]]; then
echo "---------- Install yaconf ----------" echo "---------- Install yaconf ----------"
printf "\n" | pecl install yaconf printf "\n" | pecl install yaconf
docker-php-ext-enable yaconf docker-php-ext-enable yaconf
else else
echo "yar requires PHP >= 7.0.0, installed version is ${PHP_VERSION}" echo "yar requires PHP >= 5.6.0, installed version is ${PHP_VERSION}"
fi fi
fi fi
@ -483,12 +481,12 @@ if [[ -z "${EXTENSIONS##*,sqlsrv,*}" ]]; then
printf "\n" | pecl install sqlsrv printf "\n" | pecl install sqlsrv
docker-php-ext-enable sqlsrv docker-php-ext-enable sqlsrv
else else
echo "pdo_sqlsrv requires PHP >= 7.1.0, installed version is ${PHP_VERSION}" echo "sqlsrv requires PHP >= 7.1.0, installed version is ${PHP_VERSION}"
fi fi
fi fi
if [[ -z "${EXTENSIONS##*,mcrypt,*}" ]]; then if [[ -z "${EXTENSIONS##*,mcrypt,*}" ]]; then
isPhpVersionGreaterOrEqual 7 0 isPhpVersionGreaterOrEqual 5 6
if [[ "$?" = "1" ]]; then if [[ "$?" = "1" ]]; then
echo "---------- Install mcrypt ----------" echo "---------- Install mcrypt ----------"
apk add --no-cache libmcrypt-dev libmcrypt re2c apk add --no-cache libmcrypt-dev libmcrypt re2c
@ -502,14 +500,8 @@ if [[ -z "${EXTENSIONS##*,mcrypt,*}" ]]; then
fi fi
if [[ -z "${EXTENSIONS##*,mysql,*}" ]]; then if [[ -z "${EXTENSIONS##*,mysql,*}" ]]; then
isPhpVersionGreaterOrEqual 7 0
if [[ "$?" = "1" ]]; then
echo "---------- mysql was REMOVED from PHP 7.0.0 ----------"
else
echo "---------- Install mysql ----------" echo "---------- Install mysql ----------"
docker-php-ext-install ${MC} mysql docker-php-ext-install ${MC} mysql
fi
fi fi
if [[ -z "${EXTENSIONS##*,sodium,*}" ]]; then if [[ -z "${EXTENSIONS##*,sodium,*}" ]]; then
@ -528,63 +520,39 @@ fi
if [[ -z "${EXTENSIONS##*,amqp,*}" ]]; then if [[ -z "${EXTENSIONS##*,amqp,*}" ]]; then
echo "---------- Install amqp ----------" echo "---------- Install amqp ----------"
apk add --no-cache rabbitmq-c-dev apk add --no-cache rabbitmq-c-dev
installExtensionFromTgz amqp-1.10.2 installExtensionFromTgz amqp-1.11.0
fi fi
if [[ -z "${EXTENSIONS##*,redis,*}" ]]; then if [[ -z "${EXTENSIONS##*,redis,*}" ]]; then
echo "---------- Install redis ----------" echo "---------- Install redis ----------"
isPhpVersionGreaterOrEqual 7 0 isPhpVersionGreaterOrEqual 5 6
if [[ "$?" = "1" ]]; then if [[ "$?" = "1" ]]; then
installExtensionFromTgz redis-5.2.2 installExtensionFromTgz redis-4.3.0
else else
printf "\n" | pecl install redis-4.3.0 echo "redis requires PHP >= 5.6.0, installed version is ${PHP_VERSION}"
docker-php-ext-enable redis
fi fi
fi fi
if [[ -z "${EXTENSIONS##*,apcu,*}" ]]; then if [[ -z "${EXTENSIONS##*,apcu,*}" ]]; then
echo "---------- Install apcu ----------" echo "---------- Install apcu ----------"
installExtensionFromTgz apcu-5.1.17 installExtensionFromTgz apcu-4.0.8
fi fi
if [[ -z "${EXTENSIONS##*,memcached,*}" ]]; then if [[ -z "${EXTENSIONS##*,memcached,*}" ]]; then
echo "---------- Install memcached ----------" echo "---------- Install memcached ----------"
apk add --no-cache libmemcached-dev zlib-dev apk add --no-cache libmemcached-dev zlib-dev
isPhpVersionGreaterOrEqual 7 0
if [[ "$?" = "1" ]]; then
printf "\n" | pecl install memcached-3.1.3
else
printf "\n" | pecl install memcached-2.2.0 printf "\n" | pecl install memcached-2.2.0
fi
docker-php-ext-enable memcached docker-php-ext-enable memcached
fi fi
if [[ -z "${EXTENSIONS##*,memcache,*}" ]]; then if [[ -z "${EXTENSIONS##*,memcache,*}" ]]; then
echo "---------- Install memcache ----------" echo "---------- Install memcache ----------"
isPhpVersionGreaterOrEqual 7 0 installExtensionFromTgz memcache-2.2.7
if [[ "$?" = "1" ]]; then
installExtensionFromTgz memcache-4.0.5.2
else
installExtensionFromTgz memcache-2.2.6
fi
fi fi
if [[ -z "${EXTENSIONS##*,xdebug,*}" ]]; then if [[ -z "${EXTENSIONS##*,xdebug,*}" ]]; then
echo "---------- Install xdebug ----------" echo "---------- Install xdebug ----------"
isPhpVersionGreaterOrEqual 7 0
if [[ "$?" = "1" ]]; then
isPhpVersionGreaterOrEqual 7 4
if [[ "$?" = "1" ]]; then
installExtensionFromTgz xdebug-2.9.2
else
installExtensionFromTgz xdebug-2.6.1
fi
else
installExtensionFromTgz xdebug-2.5.5 installExtensionFromTgz xdebug-2.5.5
fi
fi fi
if [[ -z "${EXTENSIONS##*,event,*}" ]]; then if [[ -z "${EXTENSIONS##*,event,*}" ]]; then
@ -598,24 +566,23 @@ if [[ -z "${EXTENSIONS##*,event,*}" ]]; then
fi fi
echo "---------- Install event again ----------" echo "---------- Install event again ----------"
installExtensionFromTgz event-2.5.6 "--ini-name event.ini" mkdir event
tar -xf event-3.0.8.tgz -C event --strip-components=1
cd event && phpize && ./configure && make && make install
docker-php-ext-enable --ini-name event.ini event
fi fi
if [[ -z "${EXTENSIONS##*,mongodb,*}" ]]; then if [[ -z "${EXTENSIONS##*,mongodb,*}" ]]; then
echo "---------- Install mongodb ----------" echo "---------- Install mongodb ----------"
installExtensionFromTgz mongodb-1.7.4 apk add --no-cache openssl-dev
installExtensionFromTgz mongodb-1.6.4=0
docker-php-ext-configure mongodb --with-mongodb-ssl=openssl
fi fi
if [[ -z "${EXTENSIONS##*,yaf,*}" ]]; then if [[ -z "${EXTENSIONS##*,yaf,*}" ]]; then
echo "---------- Install yaf ----------" echo "---------- Install yaf ----------"
isPhpVersionGreaterOrEqual 7 0 installExtensionFromTgz yaf-3.0.9
if [[ "$?" = "1" ]]; then
printf "\n" | pecl install yaf
docker-php-ext-enable yaf
else
installExtensionFromTgz yaf-2.3.5
fi
fi fi
@ -623,14 +590,7 @@ if [[ -z "${EXTENSIONS##*,swoole,*}" ]]; then
echo "---------- Install swoole ----------" echo "---------- Install swoole ----------"
# Fix: Refer to the line containing "swoole@alpine)" in file "./install-php-extensions" # Fix: Refer to the line containing "swoole@alpine)" in file "./install-php-extensions"
apk add --no-cache libstdc++ apk add --no-cache libstdc++
installExtensionFromTgz swoole-2.0.11 --enable-openssl
isPhpVersionGreaterOrEqual 7 0
if [[ "$?" = "1" ]]; then
installExtensionFromTgz swoole-4.5.2
else
installExtensionFromTgz swoole-2.0.11
fi
fi fi
if [[ -z "${EXTENSIONS##*,zip,*}" ]]; then if [[ -z "${EXTENSIONS##*,zip,*}" ]]; then
@ -638,39 +598,32 @@ if [[ -z "${EXTENSIONS##*,zip,*}" ]]; then
# Fix: https://github.com/docker-library/php/issues/797 # Fix: https://github.com/docker-library/php/issues/797
apk add --no-cache libzip-dev apk add --no-cache libzip-dev
isPhpVersionGreaterOrEqual 7 4
if [[ "$?" != "1" ]]; then
docker-php-ext-configure zip --with-libzip=/usr/include
fi
docker-php-ext-install ${MC} zip docker-php-ext-install ${MC} zip
fi fi
if [[ -z "${EXTENSIONS##*,xhprof,*}" ]]; then if [[ -z "${EXTENSIONS##*,xhprof,*}" ]]; then
echo "---------- Install XHProf ----------" echo "---------- Install XHProf ----------"
isPhpVersionGreaterOrEqual 5 6
isPhpVersionGreaterOrEqual 7 0
if [[ "$?" = "1" ]]; then if [[ "$?" = "1" ]]; then
mkdir xhprof \ mkdir xhprof \
&& tar -xf xhprof-2.2.0.tgz -C xhprof --strip-components=1 \ && tar -xf xhprof-0.9.4.tgz -C xhprof --strip-components=1 \
&& ( cd xhprof/extension/ && phpize && ./configure && make ${MC} && make install ) \ && ( cd xhprof/extension/ && phpize && ./configure && make ${MC} && make install ) \
&& docker-php-ext-enable xhprof && docker-php-ext-enable xhprof
else else
echo "---------- PHP Version>= 7.0----------" echo "---------- PHP Version>= 5.6----------"
fi fi
fi fi
if [[ -z "${EXTENSIONS##*,xlswriter,*}" ]]; then if [[ -z "${EXTENSIONS##*,xlswriter,*}" ]]; then
echo "---------- Install xlswriter ----------" echo "---------- Install xlswriter ----------"
isPhpVersionGreaterOrEqual 7 0 isPhpVersionGreaterOrEqual 5 6
if [[ "$?" = "1" ]]; then if [[ "$?" = "1" ]]; then
printf "\n" | pecl install xlswriter printf "\n" | pecl install xlswriter
docker-php-ext-enable xlswriter docker-php-ext-enable xlswriter
else else
echo "---------- PHP Version>= 7.0----------" echo "---------- PHP Version>= 5.6----------"
fi fi
fi fi
@ -689,7 +642,7 @@ fi
if [[ -z "${EXTENSIONS##*,zookeeper,*}" ]]; then if [[ -z "${EXTENSIONS##*,zookeeper,*}" ]]; then
echo "---------- Install zookeeper ----------" echo "---------- Install zookeeper ----------"
isPhpVersionGreaterOrEqual 7 0 isPhpVersionGreaterOrEqual 5 6
if [[ "$?" = "1" ]]; then if [[ "$?" = "1" ]]; then
apk add re2c apk add re2c
@ -697,7 +650,7 @@ if [[ -z "${EXTENSIONS##*,zookeeper,*}" ]]; then
printf "\n" | pecl install zookeeper printf "\n" | pecl install zookeeper
docker-php-ext-enable zookeeper docker-php-ext-enable zookeeper
else else
echo "---------- PHP Version>= 7.0----------" echo "---------- PHP Version>= 5.6----------"
fi fi
fi fi