1

所以显然有人忘记了 AWS 的 php-zip 扩展。amazon-linux-extras php7.4 存储库中没有可用于 Amazon Linux 2 的 php-zip 扩展。有人知道如何安装 php-zip 扩展吗?这是非常关键的,因为许多库都需要这个扩展。

我试过通过 Pecl 没有成功。看起来 Amazon Linux 2 上的底层软件包与 Pecl 安装方法不兼容。

/bin/sh /var/tmp/pear-build-defaultuserQfyCvq/zip-1.13.5/libtool --mode=compile cc  -I. -I/var/tmp/zip -DPHP_ATOM_INC -I/var/tmp/pear-build-defaultuserQfyCvq/zip-1.13.5/include -I/var/tmp/pear-build-defaultuserQfyCvq/zip-1.13.5/main -I/var/tmp/zip -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -I/var/tmp/zip/lib -I/var/tmp/zip/php7  -DHAVE_CONFIG_H  -g -O2   -c /var/tmp/zip/php7/php_zip.c -o php7/php_zip.lo
libtool: compile:  cc -I. -I/var/tmp/zip -DPHP_ATOM_INC -I/var/tmp/pear-build-defaultuserQfyCvq/zip-1.13.5/include -I/var/tmp/pear-build-defaultuserQfyCvq/zip-1.13.5/main -I/var/tmp/zip -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -I/var/tmp/zip/lib -I/var/tmp/zip/php7 -DHAVE_CONFIG_H -g -O2 -c /var/tmp/zip/php7/php_zip.c  -fPIC -DPIC -o php7/.libs/php_zip.o
/var/tmp/zip/php7/php_zip.c: In function 'php_zip_pcre'

更新: Pecl 方法的工作原理如下:

yum install php-devel* gcc libzip php-libzip libzip-devel zlip zip php-pear
pecl install zip

然而,这远非任何生产服务器的理想方法。仍在等待 AWS 将其作为预编译的二进制文件提供。

4

1 回答 1

1

安装它的最简单方法是暂时放弃 amazon-linux-extras php7.4 并使用 EPEL / REMI 存储库,直到亚马逊添加扩展。我不会指望他们会这样做,因为这已经是一个问题了。

您也许可以使用 Pecl 和大量的肘部油脂来完成这项工作,您还将使用各种额外的库(如 GCC、Make、libzip 等)使您的系统膨胀……

以下是使用 Amazon Linux 2 与 Epel 和 Remi 构建 docker 容器的方法:

FROM amazonlinux:latest

ENTRYPOINT /opt/remi/php74/root/usr/sbin/php-fpm --nodaemonize

ENV TERM=xterm-256color
ENV COMPOSER_ALLOW_SUPERUSER=1
ENV COMPOSER_HOME=/var/www/html
ENV PATH=$PATH:vendor/bin:/usr/local/bin:/opt/remi/php74/root/usr/bin

# Grab node RPM and enable Epel and Remi repos
RUN curl -sL https://rpm.nodesource.com/setup_12.x | bash - \
 && yum install -y \
 https://rpms.remirepo.net/enterprise/remi-release-7.rpm \
 https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm \
 yum-utils \
 && yum-config-manager enable epel \
 && yum-config-manager enable remi

RUN yum install -y \
    ruby \
    nodejs \
    php74-php \
    php74-php-fpm \
    php74-php-common \
    php74-php-cli \
    php74-php-json \
    php74-php-process \
    php74-php-xml \
    php74-php-gd \
    php74-php-gmp \
    php74-php-mysqlnd \
    php74-php-mbstring \
    php74-php-opcache \
    php74-php-pecl-zip \
    python2-pip

# Install some common dev tools on the host
RUN yum install -y \
    which \
    telnet \
    vim

# Install setup tools and AWS cli
RUN pip install setuptools awscli

# Install composer
RUN curl -sS https://getcomposer.org/installer | php && chmod 755 composer.phar && mv composer.phar /usr/local/bin/composer

# Install configuration files
COPY php-fpm/php.ini /etc/opt/remi/php74/php.ini
COPY php-fpm/www.conf /etc/opt/remi/php74/php-fpm.d/www.conf
COPY php-fpm/php-fpm.conf /etc/opt/remi/php74/php-fpm.conf

# Create folder php fpm logs we want to have log files in standard location
RUN mkdir /var/log/php-fpm

# Create user that PHP-FPM runs under
RUN groupadd php-fpm && useradd php-fpm --system --no-create-home -g php-fpm

# Give us nice prompt so we know which container we are on
ENV PS1='php-fpm \w '
于 2020-03-20T21:39:05.833 回答