用php5.6安装Debian Stretch

时间:2019-03-28 09:20:47

标签: php dockerfile debian-stretch

几天前,我们使用的是基于php版本5.6的laravel,Debian删除了jessie版本(8),因此我们需要将其升级到9,但是问题在于,没有php5.6的Debian 9很难像脚本那样使用 docker-php-ext-install 似乎在那里不工作。我将我的安装部分附加到docker-file中。如果有解决办法,将不胜感激

我试图在没有docker-php-ext-install的情况下安装pdo_mysql 但它无法找到该位置。

FROM debian:9.0
RUN apt-get update \
&& apt-get -y install \
    apt-transport-https apt-utils \
    lsb-release \
    ca-certificates \
    wget \
    mcrypt \
    libmcrypt-dev \
    git-core \
    unzip \
&& wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg \
&& echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list \
&& apt-get update \
&& apt-get -y install gnupg2 php5.6-cli php5.6-fpm \
&& apt-get update \
&& docker-php-ext-install \
    mbstring \
    pdo_mysql \
    mcrypt bcmath\
&& update-alternatives --install /usr/bin/php php /usr/bin/php5.6 90 \
&& update-alternatives --set php /usr/bin/php5.6

这是构建调用的结尾:

Reading package lists...
/bin/sh: 1: docker-php-ext-install: not found

1 个答案:

答案 0 :(得分:0)

docker-php-ext-install是官方php映像提供的命令。您只会在这些图像或基于这些图像的图像上找到它。

在docker hub上仍然存在提供php 5.6的官方docker php映像:

wget -qO- https://registry.hub.docker.com/v1/repositories/php/tags | jq '.[].name' | grep -P '^"5\.6(?!\.)'
"5.6"
"5.6-alpine"
"5.6-alpine3.4"
"5.6-alpine3.7"
"5.6-alpine3.8"
"5.6-apache"
"5.6-apache-jessie"
"5.6-apache-stretch"
"5.6-cli"
"5.6-cli-alpine"
"5.6-cli-alpine3.4"
"5.6-cli-alpine3.7"
"5.6-cli-alpine3.8"
"5.6-cli-jessie"
"5.6-cli-stretch"
"5.6-fpm"
"5.6-fpm-alpine"
"5.6-fpm-alpine3.4"
"5.6-fpm-alpine3.7"
"5.6-fpm-alpine3.8"
"5.6-fpm-jessie"
"5.6-fpm-stretch"
"5.6-jessie"
"5.6-stretch"
"5.6-zts"
"5.6-zts-alpine"
"5.6-zts-alpine3.4"
"5.6-zts-alpine3.7"
"5.6-zts-alpine3.8"
"5.6-zts-jessie"
"5.6-zts-stretch"

此外,这些图像基于debian 9构建:

docker run --rm php:5.6 cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 9 (stretch)"
NAME="Debian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

并提供docker-php-ext-install命令:

docker run --rm php:5.6 which docker-php-ext-install
/usr/local/bin/docker-php-ext-install

我建议您使用这些官方映像之一作为Dockerfile的基础。

FROM php:5.6-fpm
RUN apt-get update \
    && apt-get -y install \
        libmcrypt-dev \
        mcrypt \
    && docker-php-ext-install \
        bcmath \
        mbstring \
        mcrypt \
        pdo_mysql