Docker无法安装cURL(需要7.10.5或更高版本)

时间:2019-05-07 17:32:27

标签: php docker curl docker-compose dockerfile

尝试使用dockercomposer.json安装 Stripe 时出现错误。

这是我的composer.json

{
"require": {
    "smarty/smarty": "^3.1",
    "stripe/stripe-php": "^6.13"
    }
}

我的Dockerfile

FROM php:7.2.6-apache
RUN docker-php-ext-install mysqli curl

和我docker-compose up

时的错误日志
Build complete.
Don't forget to run 'make test'.

Installing shared extensions:     /usr/local/lib/php/extensions/no-debug-non-zts-20170718/
Installing header files:          /usr/local/include/php/
find . -name \*.gcno -o -name \*.gcda | xargs rm -f
find . -name \*.lo -o -name \*.o | xargs rm -f
find . -name \*.la -o -name \*.a | xargs rm -f
find . -name \*.so | xargs rm -f
find . -name .libs -a -type d|xargs rm -rf
rm -f libphp.la       modules/* libs/*
Configuring for:
PHP Api Version:         20170718
Zend Module Api No:      20170718
Zend Extension Api No:   320170718
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for a sed that does not truncate output... /bin/sed
checking for cc... cc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether cc accepts -g... yes
checking for cc option to accept ISO C89... none needed
checking how to run the C preprocessor... cc -E
checking for icc... no
checking for suncc... no
checking whether cc understands -c and -o together... yes
checking for system library directory... lib
checking if compiler supports -R... no
checking if compiler supports -Wl,-rpath,... yes
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
checking for PHP prefix... /usr/local
checking for PHP includes... -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib
checking for PHP extension directory... /usr/local/lib/php/extensions/no-debug-non-zts-20170718
checking for PHP installed headers prefix... /usr/local/include/php
checking if debug is enabled... no
checking if zts is enabled... no
checking for re2c... re2c
checking for re2c version... 0.16 (ok)
checking for gawk... no
checking for nawk... nawk
checking if nawk is broken... no
checking for cURL support... yes, shared
checking for pkg-config... /usr/bin/pkg-config
checking for libcurl.pc... using default path
checking for cURL 7.10.5 or greater... configure: error: cURL version 7.10.5 or later is required to compile php with cURL support
ERROR: Service 'www' failed to build: The command '/bin/sh -c docker-php-ext-install mysqli curl' returned a non-zero code: 1

我找不到任何修复程序,或者我做错了什么。感谢您的帮助

2 个答案:

答案 0 :(得分:0)

“ docker-php-ext-install”帮助程序脚本旨在安装PHP扩展,而不是系统软件包。在您的Dockerfile中,您将需要以下内容:

FROM php:7.2.6-apache
RUN apt-get update -y && apt-get install -y curl && apt-get clean -y
RUN docker-php-ext-install mysqli

mysqli是PHP扩展,因此应该可以。 (我建议使用PDO,但这是另一回事。)

答案 1 :(得分:0)

我的一个朋友给的解决方案。 cURL已经在php软件包中,无需安装。但这更加复杂。我的Dockerfile

FROM composer AS vendor

COPY composer.json .
COPY composer.lock .
RUN composer install

FROM php:7.3-apache

COPY --from=vendor /app/vendor/ vendor/
COPY www ./

RUN mkdir templates_c
RUN mkdir cache
RUN chown www-data:www-data templates_c cache

VOLUME /var/www/html/templates_c/
VOLUME /var/www/html/cache/

RUN docker-php-ext-install mysqli

我的docker-compose.yml

version: "2"
services:
    www:
        build: .
        ports: 
            - "80:80"
        volumes:
            - ./www/lib:/var/www/html/lib
            - ./www/modules:/var/www/html/modules
            - ./www/theme:/var/www/html/theme
            - ./www/index.php:/var/www/html/index.php
            - ./www/notes.php:/var/www/html/notes.php
            - ./www/tuto_array.php:/var/www/html/tuto_array.php
        links:
            - db
        networks:
            - default