Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zip extension #748

Closed
nicraMarcin opened this issue Nov 15, 2018 · 6 comments
Closed

zip extension #748

nicraMarcin opened this issue Nov 15, 2018 · 6 comments
Labels
Request Request for image modification or feature

Comments

@nicraMarcin
Copy link

--with-zlib \

Does --enable-zip shouldn't be added to image?
For example, composer downloads zips from github

@phy25
Copy link

phy25 commented Nov 15, 2018

#34 (comment)

We have to draw the line of what to include by default and currently that line is "what must be compiled into php itself versus what can be added after". *following upstreams recommendations, of course.

@wglambert wglambert added the Request Request for image modification or feature label Nov 15, 2018
@rvdlee-salesupply
Copy link

rvdlee-salesupply commented Dec 11, 2018

@nicraMarcin zip can be enabled with one command: RUN docker-php-ext-install zip in your own Dockerfile. I don't specifically understand why you would want this compiled by default like @phy25 already quoted.

@tianon
Copy link
Member

tianon commented Dec 31, 2018

Closing for the reasons noted above -- this is trivial to add after-the-fact. 👍

@tianon tianon closed this as completed Dec 31, 2018
@bwl21
Copy link

bwl21 commented Apr 5, 2019

To be honest, it is anything else than trivial. I am wasting hours with this problem trying every answer I can find on SO and wherever ...

FROM php:7.3-apache-stretch

RUN docker-php-ext-install zip

results in

checking for the location of zlib... configure: error: zip support requires ZLIB. Use --with-zlib-dir=<DIR> to specify prefix where ZLIB include and library are located
ERROR: Service 'web' failed to build: The command '/bin/sh -c docker-php-ext-install zip' returned a non-zero code: 1

FROM php:7.3-apache-stretch

RUN docker-php-ext-configure zip -with-zlib-dir=/usr/include/ \
    && docker-php-ext-install zip

yields

configure: error: Can not find zlib headers under "/usr/include/"

Any help would be highly appreaciated

@yosifkit
Copy link
Member

yosifkit commented Apr 5, 2019

Remember, you must install dependencies for your extensions manually

- Docker Hub Docs

I sometimes do library finding iteratively using docker run:

docker run:
$ docker run -it --rm php:7.3-apache-stretch docker-php-ext-install zip
...
checking for the location of zlib... configure: error: zip support requires ZLIB. Use --with-zlib-dir=<DIR> to specify prefix where ZLIB include and library are located
$ # ok, need zlib
$ docker run -it --rm php:7.3-apache-stretch sh -c 'set -eux; apt-get update; apt-get install -y zlib1g-dev; docker-php-ext-install zip'
...
checking for libzip... not found
configure: error: Please reinstall the libzip distribution
$ # ok, need libzip
$ docker run -it --rm php:7.3-apache-stretch sh -c 'set -eux; apt-get update; apt-get install -y libzip-dev zlib1g-dev; docker-php-ext-install zip'
+ apt-get update
Ign:1 http://cdn-fastly.deb.debian.org/debian stretch InRelease
Get:4 http://cdn-fastly.deb.debian.org/debian stretch-updates InRelease [91.0 kB]
Get:5 http://cdn-fastly.deb.debian.org/debian buster InRelease [158 kB]
Get:6 http://cdn-fastly.deb.debian.org/debian buster-updates InRelease [46.8 kB]
Get:7 http://cdn-fastly.deb.debian.org/debian stretch Release [118 kB]                   
Get:8 http://cdn-fastly.deb.debian.org/debian stretch Release.gpg [2434 B]               
Get:2 http://security-cdn.debian.org/debian-security stretch/updates InRelease [94.3 kB] 
Get:9 http://cdn-fastly.deb.debian.org/debian stretch-updates/main amd64 Packages [11.1 kB]
Get:10 http://cdn-fastly.deb.debian.org/debian buster/main amd64 Packages [7885 kB]      
Get:3 http://security-cdn.debian.org/debian-security buster/updates InRelease [38.3 kB]  
Get:11 http://cdn-fastly.deb.debian.org/debian stretch/main amd64 Packages [7084 kB]   
Get:12 http://security-cdn.debian.org/debian-security stretch/updates/main amd64 Packages [484 kB]
Fetched 16.0 MB in 1s (8728 kB/s)                                                   
Reading package lists... Done
+ apt-get install -y libzip-dev zlib1g-dev
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  libzip4
The following NEW packages will be installed:
  libzip-dev libzip4 zlib1g-dev
0 upgraded, 3 newly installed, 0 to remove and 5 not upgraded.
Need to get 362 kB of archives.
After this operation, 957 kB of additional disk space will be used.
Get:1 http://cdn-fastly.deb.debian.org/debian stretch/main amd64 libzip4 amd64 1.1.2-1.1+b1 [40.6 kB]
Get:2 http://cdn-fastly.deb.debian.org/debian stretch/main amd64 zlib1g-dev amd64 1:1.2.8.dfsg-5 [205 kB]
Get:3 http://cdn-fastly.deb.debian.org/debian stretch/main amd64 libzip-dev amd64 1.1.2-1.1+b1 [117 kB]
Fetched 362 kB in 0s (944 kB/s)      
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package libzip4:amd64.
(Reading database ... 13114 files and directories currently installed.)
Preparing to unpack .../libzip4_1.1.2-1.1+b1_amd64.deb ...
Unpacking libzip4:amd64 (1.1.2-1.1+b1) ...
Selecting previously unselected package zlib1g-dev:amd64.
Preparing to unpack .../zlib1g-dev_1%3a1.2.8.dfsg-5_amd64.deb ...
Unpacking zlib1g-dev:amd64 (1:1.2.8.dfsg-5) ...
Selecting previously unselected package libzip-dev:amd64.
Preparing to unpack .../libzip-dev_1.1.2-1.1+b1_amd64.deb ...
Unpacking libzip-dev:amd64 (1.1.2-1.1+b1) ...
Setting up libzip4:amd64 (1.1.2-1.1+b1) ...
Processing triggers for libc-bin (2.24-11+deb9u4) ...
Setting up zlib1g-dev:amd64 (1:1.2.8.dfsg-5) ...
Setting up libzip-dev:amd64 (1.1.2-1.1+b1) ...
+ docker-php-ext-install zip
Configuring for:
PHP Api Version:         20180731
Zend Module Api No:      20180731
Zend Extension Api No:   320180731
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-20180731
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 zip archive read/writesupport... yes, shared
checking for the location of libz... no
checking pcre install prefix... no
checking libzip... yes
checking for the location of zlib... /usr
checking for pkg-config... /usr/bin/pkg-config
checking for libzip... from pkgconfig: version 1.1.2 found in /usr/lib/x86_64-linux-gnu
checking for zip_open in -lzip... yes
checking for zip_file_set_encryption in -lzip... no
configure: WARNING: Libzip >= 1.2.0 needed for encryption support
checking for zip_libzip_version in -lzip... no
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking stdbool.h usability... yes
checking stdbool.h presence... yes
checking for stdbool.h... yes
checking fts.h usability... yes
checking fts.h presence... yes
checking for fts.h... yes
checking for int8_t... yes
checking for int16_t... yes
checking for int32_t... yes
checking for int64_t... yes
checking for uint8_t... yes
checking for uint16_t... yes
checking for uint32_t... yes
checking for uint64_t... yes
checking for ssize_t... yes
checking size of short... 2
checking size of int... 4
checking size of long... 8
checking size of long long... 8
checking size of off_t... 8
checking size of size_t... 8
checking for touch... /usr/bin/touch
checking for unzip... no
checking whether struct tm is in sys/time.h or time.h... time.h
checking for struct tm.tm_zone... yes
checking for ld used by cc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for /usr/bin/ld option to reload object files... -r
checking for BSD-compatible nm... /usr/bin/nm -B
checking whether ln -s works... yes
checking how to recognize dependent libraries... pass_all
checking dlfcn.h usability... yes
checking dlfcn.h presence... yes
checking for dlfcn.h... yes
checking the maximum length of command line arguments... 1572864
checking command to parse /usr/bin/nm -B output from cc object... ok
checking for objdir... .libs
checking for ar... ar
checking for ranlib... ranlib
checking for strip... strip
checking if cc supports -fno-rtti -fno-exceptions... no
checking for cc option to produce PIC... -fPIC
checking if cc PIC flag -fPIC works... yes
checking if cc static flag -static works... yes
checking if cc supports -c -o file.o... yes
checking whether the cc linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... no

creating libtool
appending configuration tag "CXX" to libtool
configure: creating ./config.status
config.status: creating config.h
/bin/bash /usr/src/php/ext/zip/libtool --mode=compile cc -I/usr/lib/x86_64-linux-gnu/libzip/include -I. -I/usr/src/php/ext/zip -DPHP_ATOM_INC -I/usr/src/php/ext/zip/include -I/usr/src/php/ext/zip/main -I/usr/src/php/ext/zip -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  -fstack-protector-strong -fpic -fpie -O2 -DHAVE_CONFIG_H  -fstack-protector-strong -fpic -fpie -O2   -c /usr/src/php/ext/zip/php_zip.c -o php_zip.lo 
mkdir .libs
 cc -I/usr/lib/x86_64-linux-gnu/libzip/include -I. -I/usr/src/php/ext/zip -DPHP_ATOM_INC -I/usr/src/php/ext/zip/include -I/usr/src/php/ext/zip/main -I/usr/src/php/ext/zip -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 -fstack-protector-strong -fpic -fpie -O2 -DHAVE_CONFIG_H -fstack-protector-strong -fpic -fpie -O2 -c /usr/src/php/ext/zip/php_zip.c  -fPIC -DPIC -o .libs/php_zip.o
/bin/bash /usr/src/php/ext/zip/libtool --mode=compile cc -I/usr/lib/x86_64-linux-gnu/libzip/include -I. -I/usr/src/php/ext/zip -DPHP_ATOM_INC -I/usr/src/php/ext/zip/include -I/usr/src/php/ext/zip/main -I/usr/src/php/ext/zip -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  -fstack-protector-strong -fpic -fpie -O2 -DHAVE_CONFIG_H  -fstack-protector-strong -fpic -fpie -O2   -c /usr/src/php/ext/zip/zip_stream.c -o zip_stream.lo 
 cc -I/usr/lib/x86_64-linux-gnu/libzip/include -I. -I/usr/src/php/ext/zip -DPHP_ATOM_INC -I/usr/src/php/ext/zip/include -I/usr/src/php/ext/zip/main -I/usr/src/php/ext/zip -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 -fstack-protector-strong -fpic -fpie -O2 -DHAVE_CONFIG_H -fstack-protector-strong -fpic -fpie -O2 -c /usr/src/php/ext/zip/zip_stream.c  -fPIC -DPIC -o .libs/zip_stream.o
/bin/bash /usr/src/php/ext/zip/libtool --mode=link cc -DPHP_ATOM_INC -I/usr/src/php/ext/zip/include -I/usr/src/php/ext/zip/main -I/usr/src/php/ext/zip -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  -fstack-protector-strong -fpic -fpie -O2 -DHAVE_CONFIG_H  -fstack-protector-strong -fpic -fpie -O2  -Wl,-O1 -Wl,--hash-style=both -pie -o zip.la -export-dynamic -avoid-version -prefer-pic -module -rpath /usr/src/php/ext/zip/modules  php_zip.lo zip_stream.lo -Wl,-rpath,/usr/lib/x86_64-linux-gnu -L/usr/lib/x86_64-linux-gnu -lzip -lz
cc -shared  .libs/php_zip.o .libs/zip_stream.o  -L/usr/lib/x86_64-linux-gnu -lzip -lz  -Wl,-O1 -Wl,--hash-style=both -Wl,-rpath -Wl,/usr/lib/x86_64-linux-gnu -Wl,-soname -Wl,zip.so -o .libs/zip.so
creating zip.la
(cd .libs && rm -f zip.la && ln -s ../zip.la zip.la)
/bin/bash /usr/src/php/ext/zip/libtool --mode=install cp ./zip.la /usr/src/php/ext/zip/modules
cp ./.libs/zip.so /usr/src/php/ext/zip/modules/zip.so
cp ./.libs/zip.lai /usr/src/php/ext/zip/modules/zip.la
PATH="$PATH:/sbin" ldconfig -n /usr/src/php/ext/zip/modules
----------------------------------------------------------------------
Libraries have been installed in:
   /usr/src/php/ext/zip/modules

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the `LD_RUN_PATH' environment variable
     during linking
   - use the `-Wl,--rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to `/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------

Build complete.
Don't forget to run 'make test'.

Installing shared extensions:     /usr/local/lib/php/extensions/no-debug-non-zts-20180731/
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/*
$ # success!

@bwl21
Copy link

bwl21 commented Apr 6, 2019

@yosifkit you saved my day. You pointed out what to do, and how find out what to do! Thank you so much!

just for reference: based on your help I changed my dockerfiles. I am sure they can be optimized, But they work for my project.

this is for php5.4 even if php5.4 it is out of date, but I need it for maintenance and therefore I wanted to use docker to get a running environment.

FROM php:5.4-apache

RUN a2enmod rewrite

RUN sed -i '/jessie-updates/d' /etc/apt/sources.list  # Now archived

RUN docker-php-ext-install pdo pdo_mysql mysqli mysql

RUN yes | pecl install xdebug-2.4.1 \
    && echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)" > /usr/local/etc/php/conf.d/xdebug.ini \
    && echo "xdebug.remote_enable=on" >> /usr/local/etc/php/conf.d/xdebug.ini \
    && echo "xdebug.remote_autostart=off" >> /usr/local/etc/php/conf.d/xdebug.ini

RUN usermod -u 431 www-data

RUN set -eux; apt-get update; apt-get install -y libzip-dev zlib1g-dev; docker-php-ext-install zip

for php7.3

#chose the php version here
# FROM php:7.0-apache
FROM php:7.3-apache-stretch

RUN a2enmod rewrite

RUN docker-php-ext-install pdo pdo_mysql mysqli

RUN yes | pecl install xdebug-2.7.0 \
    && echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)" > /usr/local/etc/php/conf.d/xdebug.ini \
    && echo "xdebug.remote_enable=on" >> /usr/local/etc/php/conf.d/xdebug.ini \
    && echo "xdebug.remote_autostart=off" >> /usr/local/etc/php/conf.d/xdebug.ini

RUN usermod -u 431 www-data

RUN set -eux; apt-get update; apt-get install -y libzip-dev zlib1g-dev; docker-php-ext-install zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Request Request for image modification or feature
Projects
None yet
Development

No branches or pull requests

7 participants