gpt4 book ai didi

php - Docker:如何安装 PHP 7.4 扩展 ext-http?

转载 作者:行者123 更新时间:2023-12-02 18:07:10 26 4
gpt4 key购买 nike

我想安装ext-http扩展,因为我在 php-apache 中执行 composer install 命令时出现此错误容器:

The requested PHP extension ext-http * is missing from your system. Install or enable PHP's http extension.



我的 Dockerfile:
ARG PHP_VERSION=""

FROM php:${PHP_VERSION}-apache

ENV COMPOSER_ALLOW_SUPERUSER=1

EXPOSE 80
WORKDIR /${PROJECT_DIRECTORY}

# git, unzip & zip are for composer
RUN apt-get update -qq && \
apt-get install -qy \
git \
gnupg \
libfreetype6-dev \
libjpeg62-turbo-dev \
libmcrypt-dev \
libicu-dev \
libxml2-dev \
wget \
nano \
unzip \
zip && \
curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer && \
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

# PHP Extensions
RUN docker-php-ext-install -j$(nproc) opcache pdo_mysql intl xml soap
ADD php/php.ini /usr/local/etc/php/conf.d/${PROJECT_DIRECTORY}.ini

# Apache
RUN a2enmod rewrite remoteip
ADD vhosts/vhost.conf /etc/apache2/sites-available/000-default.conf

我有 "ext-http": "*"require我的节点 composer.json .

我试过:

RUN docker-php-ext-install -j$(nproc) opcache pdo_mysql intl xml soap ext-http



我有这个错误:

Step 7/10 : RUN docker-php-ext-install -j$(nproc) opcache pdo_mysql intl xml soap ext-http ---> Running in 8ef2c127b632 error: /usr/src/php/ext/ext-http does not exist

usage: /usr/local/bin/docker-php-ext-install [-jN] ext-name [ext-name ...] ie: /usr/local/bin/docker-php-ext-install gd mysqli /usr/local/bin/docker-php-ext-install pdo pdo_mysql /usr/local/bin/docker-php-ext-install -j5 gd mbstring mysqli pdo pdo_mysql shmop

if custom ./configure arguments are necessary, see docker-php-ext-configure

Possible values for ext-name: bcmath bz2 calendar ctype curl dba dom enchant exif ffi fileinfo filter ftp gd gettext gmp hash iconv imap intl json ldap mbstring mysqli oci8 odbc opcache pcntl pdo pdo_dblib pdo_firebird pdo_mysql pdo_oci pdo_odbc pdo_pgsql pdo_sqlite pgsql phar posix pspell readline reflection session shmop simplexml snmp soap sockets sodium spl standard sysvmsg sysvsem sysvshm tidy tokenizer xml xmlreader xmlrpc xmlwriter xsl zend_test zip

Some of the above modules are already compiled into PHP; please check the output of "php -i" to see which modules are already loaded. ERROR: Service 'apache' failed to build: The command '/bin/sh -c docker-php-ext-install -j$(nproc) opcache pdo_mysql intl xml soap ext-http' returned a non-zero code: 1 Failed to deploy 'Compose: .docker': docker-compose process finished with exit code 1



请问如何安装这个扩展?

最佳答案

我发布了一个脚本,让您只需使用以下几行即可安装 http PHP 扩展(以及许多其他扩展):

ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/

RUN chmod +x /usr/local/bin/install-php-extensions && sync && \
install-php-extensions http
该脚本负责处理 PHP 版本,并安装所有必需的 APT(适用于 Debian)或 APK(适用于 Alpine)软件包。
更多详情: https://github.com/mlocati/docker-php-extension-installer

关于php - Docker:如何安装 PHP 7.4 扩展 ext-http?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59867951/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com