Docker中的Curl扩展失败,错误为“找不到CURL_OPENSSL_3”

时间:2019-12-12 10:33:54

标签: php docker docker-compose dockerfile apache2

我准备了一个Dockerfile以便将其用于最新的Symfony版本。 PHP 7.4和Apache是​​我的要求。 Dockerfile的内容如下:

FROM php:7.4.0-apache-buster

# Set frontend. We'll clean this later on!
ENV DEBIAN_FRONTEND noninteractive

# Update
RUN apt-get -y update --fix-missing && \
    apt-get upgrade -y && \
    apt-get --no-install-recommends install -y apt-utils && \
    rm -rf /var/lib/apt/lists/*

# Locale
ENV LOCALE es_ES.UTF-8

# Default Document root.
ENV DEFAULT_ROOT=/var/www/html

RUN apt-get update --fix-missing \
  && apt-get install -y \
    libfreetype6-dev \
    libicu-dev \
    libjpeg62-turbo-dev \
    libpng-dev \
    libxslt1-dev \
    git \
    build-essential \
    locales \
    libssl-dev \
    mariadb-client \
    mariadb-server \
    vim \
    wget \
    lynx \
    psmisc \
    unzip \
    tree \
    zip \
    gzip \
    cron \
    htop \
    tree \
    libzip-dev \
    libncurses5 \
    curl \
    libcurl4 \
    libcurl4-openssl-dev \
    && apt-get clean

# Install locale
RUN apt-get -qq update && \
  sed -i -e "s/# $LOCALE/$LOCALE/" /etc/locale.gen && \
  echo "LANG=$LOCALE">/etc/default/locale && \
  dpkg-reconfigure --frontend=noninteractive locales && \
  update-locale LANG=$LOCALE && \
  apt-get -q autoclean && rm -rf /var/lib/apt/lists/*

# Install useful tools and install important libaries
RUN apt-get -y update && \
    apt-get -y --no-install-recommends install nano wget dialog libsqlite3-dev libsqlite3-0 && \
    apt-get -y --no-install-recommends install default-mysql-client zlib1g-dev libzip-dev libicu-dev && \
    apt-get -y --no-install-recommends install --fix-missing apt-utils build-essential git curl libonig-dev && \ 
    apt-get -y --no-install-recommends install --fix-missing libcurl4 libcurl4-openssl-dev zip openssl && \
    rm -rf /var/lib/apt/lists/* && \
    curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

# Install xdebug
RUN pecl install xdebug-2.8.0 && \
    docker-php-ext-enable xdebug

# Install Freetype 
RUN apt-get -y update && \
    apt-get --no-install-recommends install -y libfreetype6-dev libjpeg62-turbo-dev libpng-dev && \
    rm -rf /var/lib/apt/lists/* && \
    docker-php-ext-configure gd

ADD php.ini /usr/local/etc/php/conf.d/888-auren.ini
ADD crontab /etc/crontab
ADD start.sh /start.sh
ADD 000-default.conf /etc/apache2/sites-enabled/000-default.conf

RUN usermod -u 33 www-data;

# Configure needed apache modules and disable default site
RUN a2dismod   mpm_event  cgi # mpm_worker enabled.
RUN a2enmod     \
  access_compat     \
  actions       \
  alias         \
  auth_basic        \
  authn_core        \
  authn_file        \
  authz_core        \
  authz_groupfile   \
  authz_host        \
  authz_user        \
  autoindex     \
  dir           \
  env           \
  expires       \
  filter        \
  headers       \
  mime          \
  negotiation       \
  mpm_prefork       \
  reqtimeout        \
  rewrite       \
  setenvif      \
  status        \
  ssl


# Other PHP7 Extensions

RUN docker-php-ext-install pdo_mysql && \
    docker-php-ext-install pdo_sqlite && \
    docker-php-ext-install mysqli && \
    docker-php-ext-install curl && \
    docker-php-ext-install tokenizer && \
    docker-php-ext-install json && \
    docker-php-ext-install zip && \
    docker-php-ext-install -j$(nproc) intl && \
    docker-php-ext-install mbstring && \
    docker-php-ext-install gettext

RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin --filename=composer
RUN chmod +x /usr/bin/composer

RUN apt-get install apt-transport-https
RUN apt-get update && apt-get install -y gnupg2
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
RUN apt-get update && apt-get install -y yarn

RUN curl -sL https://deb.nodesource.com/setup_10.x | bash -
RUN apt-get install -y nodejs

RUN chown -R www-data.www-data /var/www

RUN echo "ServerName localhost" >> /etc/apache2/apache2.conf

# Cleanup
RUN rm -rf /usr/src/*

# Working dir
WORKDIR ${DEFAULT_ROOT}

EXPOSE 80 443
RUN chmod +x /start.sh;

CMD ["/start.sh"]

但是然后我在容器内执行终端,并检查是否一切正常,使用“ php --version”,我得到此错误:

www-data@d29d4972facf:~/html$ php --version
php: /usr/lib/x86_64-linux-gnu/libcurl.so.4: version `CURL_OPENSSL_3' not found (required by php)

在php 7.1中,我没有这个问题,但是我需要> = 7.2才能使用Symfony 5。

编辑:

如果我添加以下行:

RUN apt-get install -y libcurl-openssl1.0-dev libcurl3

我收到此错误:

Package libcurl3 is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
However the following packages replace it:
  libcurl4

E: Unable to locate package libcurl-openssl1.0-dev
E: Couldn't find any package by glob 'libcurl-openssl1.0-dev'
E: Couldn't find any package by regex 'libcurl-openssl1.0-dev'
E: Package 'libcurl3' has no installation candidate

还有:

E: Unable to locate package libcurl-openssl1.0-dev
E: Couldn't find any package by glob 'libcurl-openssl1.0-dev'
E: Couldn't find any package by regex 'libcurl-openssl1.0-dev'

1 个答案:

答案 0 :(得分:0)

尝试: sudo apt-get install libcurl3-openssl-dev