1

So apparently somebody has forgotten about php-zip extension at AWS. There is no php-zip extension available for Amazon Linux 2 in the amazon-linux-extras php7.4 repo. Does anybody know how to get the php-zip extension installed? This is very critical as many libraries require this extension.

I've tried thru Pecl without success. It looks like the underlying packages on Amazon Linux 2 are not compatible with Pecl install method.

/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'

UPDATE: Pecl method works following the following:

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

However this far from ideal method for any production servers. Still waiting on AWS to make this available as precompiled binary.

Juha Vehnia
  • 1,255
  • 12
  • 15
  • 1
    Could you please check this - https://stackoverflow.com/questions/51290666/how-to-enable-php-7-0-zip-module-on-amazon-linux-ami – Dmitry Leiko Mar 20 '20 at 20:05
  • Zip extension is not available.... for 7.4. You can run yum list | grep php to confirm. I have ticket open with Amazon and currently they are claiming it is included in php-common but on my instances it is not for sure. I will post updated once I hear back from AWS – Juha Vehnia Mar 21 '20 at 22:06

1 Answers1

1

The easiest way to get this installed is to simply ditch amazon-linux-extras php7.4 for time being and use EPEL / REMI repos instead till Amazon adds the extension. And I wouldn't count that they ever will because this have been an issue for awhile.

You maybe able to get this working using Pecl and lots of elbow grease you will also bloat your system with all kinds of extra libraries like GCC, Make, libzip etc...

Here is how to build docker container using Amazon Linux 2 with Epel and Remi:

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 '
Juha Vehnia
  • 1,255
  • 12
  • 15