Giter VIP home page Giter VIP logo

docker-php-extension-installer's Introduction

Downloaded GitHub Releases Docker Hub pulls Test recent

Easy installation of PHP extensions in official PHP Docker images

This repository contains a script that can be used to easily install a PHP extension inside the official PHP Docker images.

The script will install all the required APT/APK packages; at the end of the script execution, the no-more needed packages will be removed so that the image will be much smaller.

Supported docker images are:

  • Debian-based docker images: since jessie (Debian 8) (minimum PHP version: 5.5)
  • Alpine-based docker images: since Alpine 3.9 (minimum PHP version: 7.1)

See also the notes in the Special requirements section.

Usage

You have many ways to use this script within your Dockerfiles.

Here's a list of sample Dockerfiles that install the GD and xdebug PHP extensions:

Downloading the script on the fly with ADD

FROM php:7.2-cli

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

RUN install-php-extensions gd xdebug

Downloading the script on the fly with curl

FROM php:7.2-cli

RUN curl -sSLf \
        -o /usr/local/bin/install-php-extensions \
        https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions && \
    chmod +x /usr/local/bin/install-php-extensions && \
    install-php-extensions gd xdebug

Direct execution with curl

FROM php:8.2-cli

RUN curl -sSL https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions -o - | sh -s \
      gd xdebug

Copying the script from a Docker image

FROM php:7.2-cli

COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/

RUN install-php-extensions gd xdebug

Warning: by using this method you may use an outdated version of the mlocati/php-extension-installer image. You may want to run docker pull mlocati/php-extension-installer in order to use an up-to-date version.

Using the script of a Docker image

RUN  --mount=type=bind,from=mlocati/php-extension-installer:latest,source=/usr/bin/install-php-extensions,target=/usr/local/bin/install-php-extensions \
      install-php-extensions gd xdebug

Warning: by using this method you may use an outdated version of the mlocati/php-extension-installer image. You may want to run docker pull mlocati/php-extension-installer in order to use an up-to-date version.

Installing specific versions of an extension

Simply append -<version> to the module name. For example:

install-php-extensions xdebug-2.9.7

The script also supports resolving compatible versions by prefixing the version with a caret (^). For example:

# Install the most recent xdebug 2.x version (for example 2.9.8)
install-php-extensions xdebug-^2
# Install the most recent xdebug 2.8.x version (for example 2.8.1)
install-php-extensions xdebug-^2.8

Please remark that with the syntax above you'll get the vary latest compatible version, which may be unstable. In order to install the most recent stable version, you can append @stable:

# Install the most recent STABLE xdebug 3.x version (for example 3.2.2)
install-php-extensions xdebug-^3@stable

(valid suffixes are: @snapshot, @devel, @alpha, @beta, and @stable)

Pre-release versions extensions available on PECL can be setup by suffixing the extension's name with its state i.e. alpha, beta, rc, preview, devel or snapshot. For example:

install-php-extensions xdebug-beta

TIP: When the latest version available on PECL is not stable, and you want to keep the last stable version, force it by suffixing the extension's name with the stable state. For example:

install-php-extensions mongodb-stable

Installing an extension from its source code

You can also install PHP extensions from source code (provided that it comes with a package.xml or a package2.xml file).

Accepted formats are:

  • A short version for repositories hosted on GitHub.
    For example, for the php-memcached-dev/php-memcached GitHub repository, you can simply write:
    # Install from a specific commit (full commit SHA-1)
    install-php-extensions php-memcached-dev/php-memcached@8f106564e6bb005ca6100b12ccc89000daafa9d8
    # Install from a specific commit (short commit SHA-1)
    install-php-extensions php-memcached-dev/php-memcached@8f106564e6bb
    # Install from tag v3.2.0RC2
    install-php-extensions php-memcached-dev/[email protected]
    install-php-extensions php-memcached-dev/php-memcached@refs/tags/v3.2.0RC2
    # Install from branch master
    install-php-extensions php-memcached-dev/php-memcached@master
    install-php-extensions php-memcached-dev/php-memcached@refs/heads/master
  • An URL providing an archive containing the source code.
    Examples:
    # tgz archive for commit 8f106564e6bb005ca6100b12ccc89000daafa9d8
    install-php-extensions https://codeload.github.com/php-memcached-dev/php-memcached/tar.gz/8f106564e6bb005ca6100b12ccc89000daafa9d8
    # tgz archive for tag v3.1.5
    install-php-extensions https://codeload.github.com/php-memcached-dev/php-memcached/tar.gz/refs/tags/v3.1.5
    # tgz archive for branch master
    install-php-extensions https://codeload.github.com/php-memcached-dev/php-memcached/tar.gz/refs/heads/master
  • The absolute path of a local directory.
    Examples:
    # Download the source code
    curl -o /tmp/source.tgz https://codeload.github.com/php-memcached-dev/php-memcached/tar.gz/refs/tags/v3.1.5
    tar xzf /tmp/source.tgz -C /tmp
    install-php-extensions /tmp/php-memcached-3.1.5
    

Installing composer

You can also install composer, and you also can specify a major version of it, or a full version.

Examples:

# Install the latest version
install-php-extensions @composer
# Install the latest 1.x version
install-php-extensions @composer-1
# Install a specific version
install-php-extensions @composer-2.0.2

Issue with Let's Encrypt certificates

The root CA certificate of Let's Encrypt changes (more details here).
That breaks old linux distributions, namely:

  • Debian Jessie (8)
  • Debian Stretch (9)
  • Alpine Linux 3.7
  • Alpine Linux 3.8

This script can fix this issue: simply pass @fix_letsencrypt as an argument:

install-php-extensions @fix_letsencrypt

Supported PHP extensions

Extension PHP 5.5 PHP 5.6 PHP 7.0 PHP 7.1 PHP 7.2 PHP 7.3 PHP 7.4 PHP 8.0 PHP 8.1 PHP 8.2 PHP 8.3
amqp
apcu
apcu_bc
ast
bcmath
bitset
blackfire
bz2
calendar
cassandra*
cmark
csv
dba
ddtrace*
decimal
ds
ecma_intl*
enchant
ev
event
excimer
exif
ffi
ftp
gd
gearman
geoip
geos*
geospatial
gettext
gmagick
gmp
gnupg
grpc
http
igbinary
imagick
imap
inotify
interbase
intl
ion
ioncube_loader
jsmin
json_post
jsonpath
ldap
luasandbox
lz4*
lzf
mailparse
maxminddb
mcrypt
memcache
memcached
memprof*
mongo
mongodb
mosquitto
msgpack
mssql
mysql
mysqli
newrelic
oauth
oci8
odbc
opcache
opencensus
openswoole
opentelemetry
parallel*
parle*
pcntl
pcov
pdo_dblib
pdo_firebird
pdo_mysql
pdo_oci
pdo_odbc
pdo_pgsql
pdo_sqlsrv*
pgsql
php_trie
pkcs11
pq
propro
protobuf
pspell
pthreads*
raphf
rdkafka
recode
redis
relay
saxon*
seasclick
seaslog
shmop
simdjson*
smbclient
snappy
snmp
snuffleupagus
soap
sockets
sodium*
solr
sourceguardian
spx
sqlsrv*
ssh2
stomp
swoole
sybase_ct
sync
sysvmsg
sysvsem
sysvshm
tensor
tideways
tidy
timezonedb
uopz
uploadprogress
uuid
uv
vips*
vld
wddx
wikidiff2*
xdebug
xdiff
xhprof
xlswriter
xmldiff
xmlrpc
xsl
yac
yaml
yar
zephir_parser
zip
zmq
zookeeper
zstd

Number of supported extensions: 146

PS: the pre-installed PHP extensions are excluded from this list. You can list them with the following command (change php:7.2-cli to reflect the PHP version you are interested in):

$ docker run --rm php:7.2-cli php -m
[PHP Modules]
Core
ctype
curl
date
dom
fileinfo
filter
ftp
hash
iconv
json
libxml
mbstring
mysqlnd
openssl
pcre
PDO
pdo_sqlite
Phar
posix
readline
Reflection
session
SimpleXML
sodium
SPL
sqlite3
standard
tokenizer
xml
xmlreader
xmlwriter
zlib

[Zend Modules]

Configuration

You can configure the behavior of the script, as well as fine-tune some extensions in order fit your needs, by using environment variables.

Here's an example:

IPE_LZF_BETTERCOMPRESSION=1 install-php-extensions lzf

Here's the list of all the supported environment variables:

Extension Environment variable Description
IPE_DEBUG=1 By setting this environment variable, the script will print all the commands it executes (it will be very verbose, useful only for debug purposes)
IPE_PROCESSOR_COUNT By default all available processors. Set this environment variable to override the number of processors detected by the script (used for parallel compilation)
IPE_DONT_ENABLE=1 By default the script will install and enable the extensions.
If you want to only install them (without enabling them) you can set this environment variable.
To enable the extensions at a later time you can execute the command docker-php-ext-enable-<extension> (for example: docker-php-ext-enable-xdebug).
Beware: installing some PHP extensions requires that other PHP extensions are already enabled, so use this feature wisely.
IPE_SKIP_CHECK=1 By default the script will check if the extensions can be enabled: if you want to skip this check, you can use this flag.
Beware: extensions may be enabled even if they break PHP: use this function wisely.
IPE_KEEP_SYSPKG_CACHE=1 By default the script will clear the apt/apk/pear cache in order to save disk space. You can disable it by setting this environment variable
lzf IPE_LZF_BETTERCOMPRESSION=1 By default install-php-extensions compiles the lzf extension to prefer speed over size; you can use this environment variable to compile it preferring size over speed
event IPE_EVENT_NAMESPACE=... By default, the event classes are defined in the root namespace. You can use this environment variable to specify a custom namespace
gd IPE_GD_WITHOUTAVIF=1 Since PHP 8.1, gd supports the AVIF format. Enabling it requires compiling libaom/libdav1d/libyuv/libavif on Debian 11- and Alpine 3.14-, which is time-consuming. You can disable AVIF support by setting this environment variable on Debian 11- and Alpine 3.14-
oci8 & pdo_oci IPE_INSTANTCLIENT_BASIC=1 The oci8 and pdo_oci PHP extensions require Oracle Instant Client. In order to save disk space, we install the Basic Lite version: if you want to install the Basic (non-lite) version simply set this environment variable
http, intl, mongodb IPE_ICU_EN_ONLY=1 Some extensions require the ICU library, use this flag to install a smaller, but English-only, ICU library on Alpine 3.16 and later
pspell IPE_ASPELL_LANGUAGES='...' Configure the languages to be made available (for example: IPE_ASPELL_LANGUAGES='en fr'). If omitted, we'll assume en
IPE_DEB_ARCHIVE & IPE_DEB_ARCHIVE_SECURITY The APT packages of very old Debian versions (eg Jessie) may have been archived: you can use these environment variables to specify custom URLs of these APT archives
newrelic IPE_NEWRELIC_DAEMON=1 Install the NewRelic daemon
newrelic NR_INSTALL_KEY Your New Relic license key

Special requirements

Some extensions have special requirements:

Extension Requirements
cassandra • Not available in jessie docker images
• Not available in stretch docker images
• Not available in buster docker images
• Not available in bullseye docker images
• Not available in bookworm docker images
ddtrace Not available in jessie docker images
ecma_intl • Not available in buster docker images
• Not available in bullseye docker images
geos • Not available in alpine3.9 docker images
• Not available in alpine3.10 docker images
lz4 Not available in jessie docker images
memprof • Not available in alpine3.9 docker images
• Not available in alpine3.10 docker images
• Not available in alpine3.11 docker images
• Not available in alpine3.12 docker images
• Not available in alpine3.13 docker images
• Not available in alpine3.14 docker images
• Not available in alpine3.15 docker images
parallel Requires images with PHP compiled with thread-safety enabled (zts)
parle Not available in jessie docker images
pdo_sqlsrv Not available in ARM architectures
pthreads Requires images with PHP compiled with thread-safety enabled (zts)
saxon Not available in alpine docker images
simdjson • Not available in jessie docker images
• Not available in stretch docker images
sodium Not available in jessie docker images
sqlsrv • Not available in 7.1-alpine3.9 docker images
• Not available in 7.1-alpine3.10 docker images
• Not available in ARM architectures
vips • Not available in alpine3.9 docker images
• Not available in jessie docker images
wikidiff2 • Not available in jessie docker images
• Not available in stretch docker images

How do I know which Linux distribution I am using?

You can run this command:

cat /etc/os-release

For example:

  • for Debian 11 (Bullseye) you'll see:
    PRETTY_NAME="Debian GNU/Linux 11 (bullseye)"
  • for Alpine Linux 3.14 you'll see:
    PRETTY_NAME="Alpine Linux v3.14"

Tests

When submitting a pull request, a GitHub Action is executed to check if affected PHP extensions actually work (see below).

Furthermore, we also check that new versions of extensions in the PECL repository will still work. This is done on a scheduled basis with another GitHub Action.
In case of failure, a message is sent to a Telegram Channel.
Feel free to subscribe to it to receive failure notifications.

How to contribute

Formatting code

Before submitting any pull request, you should execute the lint script in the scripts directory (or lint.bat on Windows).

If you don't do that, and if there's a coding style error, you'll see that the Check shell coding style and/or the Check PHP coding style GitHub Actions will fail.

The error will be something like this:

--- filename.orig
+++ filename
@@ -line number,7 +line number,7 @@
     good line of code #1
     good line of code #2
     good line of code #3
-    the original line with a wrong coding style
+    the line wrong coding style that has been corrected
     good line of code #4
     good line of code #5
     good line of code #6

So, you should fix highlighted line (the one(s) at line number) by replacing what you see after the - with what you see after the +

Adding support to a new PHP extension?

  1. change the install-php-extensions script
  2. update the data/supported-extensions file, adding a new line with the handle of the extension and the list of supported PHP versions
  3. if the extension requires ZTS images:
    add a new line to the data/special-requirements file, with the extension handle followed by a space and zts

See this pull request for an example.

Changing the supported PHP versions for an already supported PHP extension?

  1. change the install-php-extensions script
  2. update the data/supported-extensions file, adding the new PHP version to the existing line corresponding to the updated extension

See this pull request for an example.

Improving code for an already supported extension?

If you change some code that affects one or more extensions, please add a line with Test: extension1, extension2 to the message of one of the pull request commits. That way, the test jobs will check the extension even if you don't touch the data/supported-extensions file.

Here's an example of a commit message:

Improve the GD and ZIP extensions

Test: gd, zip

Tests only check the installation of a single PHP extension at a time. If you want to test installing more PHP extensions at the same time, use a commit message like this:

Improve the GD and ZIP extensions

Test: gd+zip

If your pull request contains multiple commits, we'll check the "Test:" message of every commit. If you want to stop parsing next commits, add -STOP- in the "Test:" line, for example:

Improve the GD and ZIP extensions

Test: gd, zip, -STOP-

See this pull request for an example.

PHP requirements and configure options

PHP extensions published on the PECL archive contain a package.xml (or package2.xml) file describing the supported PHP versions and the options that can be used to compile it. When we add support for a new PHP extension, and when a new version of a PHP extension is released, we have to check those constraints.

It's a rather tedious task, so I developed a project that lets you easily check those constraints: you can find it at https://mlocati.github.io/pecl-info (here you can find its source code).

For the maintainers

See the MAINTAINERS.md file.

Do you want to really say thank you?

You can offer me a monthly coffee or a one-time coffee 😉

docker-php-extension-installer's People

Contributors

alexeykupershtokh avatar apeschar avatar b1rdex avatar bestlong avatar chrisb9 avatar danog avatar fedotov-as avatar freezy-sk avatar intersectraven avatar itscaro avatar lakostis avatar legion112 avatar leonboot avatar llaville avatar mathiasgrimm avatar maxm86545 avatar mcfedr avatar michaelgooden avatar mjanda avatar mkiejda avatar mlocati avatar mvorisek avatar mwijngaard avatar nielsdos avatar pataar avatar pavel-mironchik avatar ramunasd avatar ro0nl avatar tillkruss avatar yannoff avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

docker-php-extension-installer's Issues

Support custom temp directory

On latest alpine docker images /tmp is mounted as noexec.
This causes some extensions (in my case xlswriter from pecl) to fail to install.
The path /tmp is hardcoded in the script making it hard to work around this.

Current workaround I use is:

# mkdir /tmp2 
# ln -s /tmp2 /tmp/pear

This is obviously an ugly solution and could be solved much better in this script.

Ideally it would also check whatever temp directory it is using is not mounted with noexec and provide a more informative error message.

IMAP extension install broken on Alpine 3.11

When trying to install IMAP extension on the php:7.3.14-fpm-alpine (Alpine 3.11), the scripts ends with the following error message :

/usr/local/bin # install-php-extensions imap
fetch http://dl-cdn.alpinelinux.org/alpine/v3.11/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.11/community/x86_64/APKINDEX.tar.gz
v3.11.3-63-g6739467f83 [http://dl-cdn.alpinelinux.org/alpine/v3.11/main]
v3.11.3-60-gb3a10d424a [http://dl-cdn.alpinelinux.org/alpine/v3.11/community]
OK: 11264 distinct packages available
FAILED TO LIST THE WHOLE PACKAGE LIST FOR
c-client libressl2.7-libtls 

COMMAND OUTPUT:
ERROR: unsatisfiable constraints:
  libressl2.7-libtls (missing):
    required by: world[libressl2.7-libtls]

ERROR: apk failed

When using Alpine 3.10 version (php:7.3.14-fpm-alpine3.10) the problem doesn't occur.

AMQP module doesn't seem to be buildable on PHP8

FROM php:8.0.0RC5-cli-alpine
COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/bin/install-php-extensions
RUN install-php-extensions amqp

output:

### INSTALLING PECL MODULE amqp ###
Updating channel "pecl.php.net"
Channel "pecl.php.net" is up to date
downloading amqp-1.10.2.tgz ...
Starting to download amqp-1.10.2.tgz (107,350 bytes)
.........................done: 107,350 bytes
28 source files, building
running: phpize
Configuring for:
PHP Api Version:         20200930
Zend Module Api No:      20200930
Zend Extension Api No:   420200930
Set the path to librabbitmq install prefix [autodetect] : building in /tmp/pear/temp/pear-build-defaultuserbIlnki/amqp-1.10.2
running: /tmp/pear/temp/amqp/configure --with-php-config=/usr/local/bin/php-config --with-librabbitmq-dir
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 pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
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 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-musl
checking host system type... x86_64-pc-linux-musl
checking target system type... x86_64-pc-linux-musl
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-20200930
checking for PHP installed headers prefix... /usr/local/include/php
checking if debug is enabled... no
checking if zts is enabled... no
checking for gawk... no
checking for nawk... no
checking for awk... awk
checking if awk is broken... no
checking for amqp support... yes, shared
checking for amqp... yes, shared
checking for supported PHP versions... supported (8.0.0RC5)
yes
checking for pkg-config... /usr/bin/pkg-config
checking for amqp using pkg-config... found version 0.10.0
checking for a sed that does not truncate output... /bin/sed
checking for ld used by cc... /usr/x86_64-alpine-linux-musl/bin/ld
checking if the linker (/usr/x86_64-alpine-linux-musl/bin/ld) is GNU ld... yes
checking for /usr/x86_64-alpine-linux-musl/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 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 dlfcn.h usability... yes
checking dlfcn.h presence... yes
checking for dlfcn.h... yes
checking the maximum length of command line arguments... 98304
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/x86_64-alpine-linux-musl/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: patching config.h.in
configure: creating ./config.status
config.status: creating config.h
running: make
/bin/sh /tmp/pear/temp/pear-build-defaultuserbIlnki/amqp-1.10.2/libtool --mode=compile cc -I. -I/tmp/pear/temp/amqp -I/tmp/pear/temp/pear-build-defaultuserbIlnki/amqp-1.10.2/include -I/tmp/pear/temp/pear-build-defaultuserbIlnki/amqp-1.10.2/main -I/tmp/pear/temp/amqp -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  -DHAVE_CONFIG_H  -g -O2    -c /tmp/pear/temp/amqp/amqp.c -o amqp.lo
mkdir .libs
 cc -I. -I/tmp/pear/temp/amqp -I/tmp/pear/temp/pear-build-defaultuserbIlnki/amqp-1.10.2/include -I/tmp/pear/temp/pear-build-defaultuserbIlnki/amqp-1.10.2/main -I/tmp/pear/temp/amqp -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 -DHAVE_CONFIG_H -g -O2 -c /tmp/pear/temp/amqp/amqp.c  -fPIC -DPIC -o .libs/amqp.o
In file included from /tmp/pear/temp/amqp/php_amqp.h:54,
                 from /tmp/pear/temp/amqp/amqp.c:43:
/tmp/pear/temp/amqp/amqp_connection_resource.h:38:73: error: expected ';', ',' or ')' before 'TSRMLS_DC'
   38 | void php_amqp_prepare_for_disconnect(amqp_connection_resource *resource TSRMLS_DC);
      |                                                                         ^~~~~~~~~
In file included from /tmp/pear/temp/amqp/php_amqp.h:54,
                 from /tmp/pear/temp/amqp/amqp.c:43:
/tmp/pear/temp/amqp/amqp_connection_resource.h:62:142: error: expected ';', ',' or ')' before 'TSRMLS_DC'
   62 | int php_amqp_connection_resource_error(amqp_rpc_reply_t reply, char **message, amqp_connection_resource *resource, amqp_channel_t channel_id TSRMLS_DC);
      |                                                                                                                                              ^~~~~~~~~
/tmp/pear/temp/amqp/amqp_connection_resource.h:63:181: error: expected ';', ',' or ')' before 'TSRMLS_DC'
   63 | int php_amqp_connection_resource_error_advanced(amqp_rpc_reply_t reply, char **message, amqp_connection_resource *resource, amqp_channel_t channel_id, amqp_channel_object *channel TSRMLS_DC);
      |                                                                                                                                                                                     ^~~~~~~~~
/tmp/pear/temp/amqp/amqp_connection_resource.h:66:96: error: expected ';', ',' or ')' before 'TSRMLS_DC'
   66 | int php_amqp_set_resource_read_timeout(amqp_connection_resource *resource, double read_timeout TSRMLS_DC);
      |                                                                                                ^~~~~~~~~
/tmp/pear/temp/amqp/amqp_connection_resource.h:67:98: error: expected ';', ',' or ')' before 'TSRMLS_DC'
   67 | int php_amqp_set_resource_write_timeout(amqp_connection_resource *resource, double write_timeout TSRMLS_DC);
      |                                                                                                  ^~~~~~~~~
/tmp/pear/temp/amqp/amqp_connection_resource.h:70:94: error: expected ';', ',' or ')' before 'TSRMLS_DC'
   70 | int php_amqp_set_resource_rpc_timeout(amqp_connection_resource *resource, double rpc_timeout TSRMLS_DC);
      |                                                                                              ^~~~~~~~~
/tmp/pear/temp/amqp/amqp_connection_resource.h:78:112: error: expected ';', ',' or ')' before 'TSRMLS_DC'
   78 | amqp_connection_resource *connection_resource_constructor(amqp_connection_params *params, zend_bool persistent TSRMLS_DC);
      |                                                                                                                ^~~~~~~~~
In file included from /tmp/pear/temp/amqp/amqp.c:43:
/tmp/pear/temp/amqp/php_amqp.h:378:147: error: expected ';', ',' or ')' before 'TSRMLS_DC'
  378 | int php_amqp_error(amqp_rpc_reply_t reply, char **message, amqp_connection_resource *connection_resource, amqp_channel_resource *channel_resource TSRMLS_DC);
      |                                                                                                                                                   ^~~~~~~~~
/tmp/pear/temp/amqp/php_amqp.h:379:176: error: expected ';', ',' or ')' before 'TSRMLS_DC'
  379 | int php_amqp_error_advanced(amqp_rpc_reply_t reply, char **message, amqp_connection_resource *connection_resource, amqp_channel_resource *channel_resource, int fail_on_errors TSRMLS_DC);
      |                                                                                                                                                                                ^~~~~~~~~
/tmp/pear/temp/amqp/php_amqp.h:384:144: error: expected ';', ',' or ')' before 'TSRMLS_DC'
  384 | void php_amqp_zend_throw_exception(amqp_rpc_reply_t reply, zend_class_entry *exception_ce, const char *message, PHP5to7_param_long_type_t code TSRMLS_DC);
      |                                                                                                                                                ^~~~~~~~~
/tmp/pear/temp/amqp/php_amqp.h:385:97: error: expected ';', ',' or ')' before 'TSRMLS_DC'
  385 | void php_amqp_zend_throw_exception_short(amqp_rpc_reply_t reply, zend_class_entry *exception_ce TSRMLS_DC);
      |                                                                                                 ^~~~~~~~~
In file included from /tmp/pear/temp/amqp/amqp.c:44:
/tmp/pear/temp/amqp/amqp_connection.h:28:67: error: expected ';', ',' or ')' before 'TSRMLS_DC'
   28 | void php_amqp_disconnect_force(amqp_connection_resource *resource TSRMLS_DC);
      |                                                                   ^~~~~~~~~
In file included from /tmp/pear/temp/amqp/amqp.c:45:
/tmp/pear/temp/amqp/amqp_basic_properties.h:29:57: error: expected ';', ',' or ')' before 'TSRMLS_DC'
   29 | void parse_amqp_table(amqp_table_t *table, zval *result TSRMLS_DC);
      |                                                         ^~~~~~~~~
/tmp/pear/temp/amqp/amqp_basic_properties.h:30:78: error: expected ';', ',' or ')' before 'TSRMLS_DC'
   30 | void php_amqp_basic_properties_extract(amqp_basic_properties_t *p, zval *obj TSRMLS_DC);
      |                                                                              ^~~~~~~~~
/tmp/pear/temp/amqp/amqp_basic_properties.h:33:90: error: expected ';', ',' or ')' before 'TSRMLS_DC'
   33 | void php_amqp_basic_properties_convert_to_zval(amqp_basic_properties_t *props, zval *obj TSRMLS_DC);
      |                                                                                          ^~~~~~~~~
/tmp/pear/temp/amqp/amqp_basic_properties.h:34:60: error: expected ';', ',' or ')' before 'TSRMLS_DC'
   34 | void php_amqp_basic_properties_set_empty_headers(zval *obj TSRMLS_DC);
      |                                                            ^~~~~~~~~
In file included from /tmp/pear/temp/amqp/amqp.c:47:
/tmp/pear/temp/amqp/amqp_channel.h:25:93: error: expected ';', ',' or ')' before 'TSRMLS_DC'
   25 | void php_amqp_close_channel(amqp_channel_resource *channel_resource, zend_bool check_errors TSRMLS_DC);
      |                                                                                             ^~~~~~~~~
In file included from /tmp/pear/temp/amqp/amqp.c:48:
/tmp/pear/temp/amqp/amqp_envelope.h:25:83: error: expected ';', ',' or ')' before 'TSRMLS_DC'
   25 | void convert_amqp_envelope_to_zval(amqp_envelope_t *amqp_envelope, zval *envelope TSRMLS_DC);
      |                                                                                   ^~~~~~~~~
In file included from /tmp/pear/temp/amqp/php_amqp.h:49,
                 from /tmp/pear/temp/amqp/amqp.c:43:
/tmp/pear/temp/amqp/amqp.c: In function 'zm_startup_amqp':
/tmp/pear/temp/amqp/amqp.c:132:103: error: 'TSRMLS_C' undeclared (first use in this function); did you mean 'TSRM_H'?
  132 |  amqp_exception_class_entry = PHP5to7_zend_register_internal_class_ex(&ce, zend_exception_get_default(TSRMLS_C));
      |                                                                                                       ^~~~~~~~
/tmp/pear/temp/amqp/php7_support.h:63:103: note: in definition of macro 'PHP5to7_zend_register_internal_class_ex'
   63 | #define PHP5to7_zend_register_internal_class_ex(ce, parent_ce) zend_register_internal_class_ex((ce), (parent_ce) TSRMLS_CC)
      |                                                                                                       ^~~~~~~~~
/tmp/pear/temp/amqp/amqp.c:132:103: note: each undeclared identifier is reported only once for each function it appears in
  132 |  amqp_exception_class_entry = PHP5to7_zend_register_internal_class_ex(&ce, zend_exception_get_default(TSRMLS_C));
      |                                                                                                       ^~~~~~~~
/tmp/pear/temp/amqp/php7_support.h:63:103: note: in definition of macro 'PHP5to7_zend_register_internal_class_ex'
   63 | #define PHP5to7_zend_register_internal_class_ex(ce, parent_ce) zend_register_internal_class_ex((ce), (parent_ce) TSRMLS_CC)
      |                                                                                                       ^~~~~~~~~
/tmp/pear/temp/amqp/amqp.c:132:76: error: too many arguments to function 'zend_exception_get_default'
  132 |  amqp_exception_class_entry = PHP5to7_zend_register_internal_class_ex(&ce, zend_exception_get_default(TSRMLS_C));
      |                                                                            ^~~~~~~~~~~~~~~~~~~~~~~~~~
/tmp/pear/temp/amqp/php7_support.h:63:103: note: in definition of macro 'PHP5to7_zend_register_internal_class_ex'
   63 | #define PHP5to7_zend_register_internal_class_ex(ce, parent_ce) zend_register_internal_class_ex((ce), (parent_ce) TSRMLS_CC)
      |                                                                                                       ^~~~~~~~~
In file included from /tmp/pear/temp/amqp/amqp.c:31:
/usr/local/include/php/Zend/zend_exceptions.h:51:28: note: declared here
   51 | ZEND_API zend_class_entry *zend_exception_get_default(void);
      |                            ^~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /tmp/pear/temp/amqp/php_amqp.h:49,
                 from /tmp/pear/temp/amqp/amqp.c:43:
/tmp/pear/temp/amqp/php7_support.h:63:114: error: expected ')' before 'TSRMLS_CC'
   63 | #define PHP5to7_zend_register_internal_class_ex(ce, parent_ce) zend_register_internal_class_ex((ce), (parent_ce) TSRMLS_CC)
      |                                                                                                                  ^~~~~~~~~
/tmp/pear/temp/amqp/amqp.c:132:31: note: in expansion of macro 'PHP5to7_zend_register_internal_class_ex'
  132 |  amqp_exception_class_entry = PHP5to7_zend_register_internal_class_ex(&ce, zend_exception_get_default(TSRMLS_C));
      |                               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/tmp/pear/temp/amqp/php7_support.h:63:114: error: expected ')' before 'TSRMLS_CC'
   63 | #define PHP5to7_zend_register_internal_class_ex(ce, parent_ce) zend_register_internal_class_ex((ce), (parent_ce) TSRMLS_CC)
      |                                                                                                                  ^~~~~~~~~
/tmp/pear/temp/amqp/amqp.c:135:42: note: in expansion of macro 'PHP5to7_zend_register_internal_class_ex'
  135 |  amqp_connection_exception_class_entry = PHP5to7_zend_register_internal_class_ex(&ce, amqp_exception_class_entry);
      |                                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/tmp/pear/temp/amqp/php7_support.h:63:114: error: expected ')' before 'TSRMLS_CC'
   63 | #define PHP5to7_zend_register_internal_class_ex(ce, parent_ce) zend_register_internal_class_ex((ce), (parent_ce) TSRMLS_CC)
      |                                                                                                                  ^~~~~~~~~
/tmp/pear/temp/amqp/amqp.c:138:39: note: in expansion of macro 'PHP5to7_zend_register_internal_class_ex'
  138 |  amqp_channel_exception_class_entry = PHP5to7_zend_register_internal_class_ex(&ce, amqp_exception_class_entry);
      |                                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/tmp/pear/temp/amqp/php7_support.h:63:114: error: expected ')' before 'TSRMLS_CC'
   63 | #define PHP5to7_zend_register_internal_class_ex(ce, parent_ce) zend_register_internal_class_ex((ce), (parent_ce) TSRMLS_CC)
      |                                                                                                                  ^~~~~~~~~
/tmp/pear/temp/amqp/amqp.c:141:37: note: in expansion of macro 'PHP5to7_zend_register_internal_class_ex'
  141 |  amqp_queue_exception_class_entry = PHP5to7_zend_register_internal_class_ex(&ce, amqp_exception_class_entry);
      |                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/tmp/pear/temp/amqp/php7_support.h:63:114: error: expected ')' before 'TSRMLS_CC'
   63 | #define PHP5to7_zend_register_internal_class_ex(ce, parent_ce) zend_register_internal_class_ex((ce), (parent_ce) TSRMLS_CC)
      |                                                                                                                  ^~~~~~~~~
/tmp/pear/temp/amqp/amqp.c:144:40: note: in expansion of macro 'PHP5to7_zend_register_internal_class_ex'
  144 |  amqp_envelope_exception_class_entry = PHP5to7_zend_register_internal_class_ex(&ce, amqp_exception_class_entry);
      |                                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/tmp/pear/temp/amqp/amqp.c:145:105: error: expected ')' before 'TSRMLS_CC'
  145 |  zend_declare_property_null(amqp_envelope_exception_class_entry, ZEND_STRL("envelope"), ZEND_ACC_PUBLIC TSRMLS_CC);
      |                                                                                                         ^~~~~~~~~
In file included from /tmp/pear/temp/amqp/php_amqp.h:49,
                 from /tmp/pear/temp/amqp/amqp.c:43:
/tmp/pear/temp/amqp/php7_support.h:63:114: error: expected ')' before 'TSRMLS_CC'
   63 | #define PHP5to7_zend_register_internal_class_ex(ce, parent_ce) zend_register_internal_class_ex((ce), (parent_ce) TSRMLS_CC)
      |                                                                                                                  ^~~~~~~~~
/tmp/pear/temp/amqp/amqp.c:148:40: note: in expansion of macro 'PHP5to7_zend_register_internal_class_ex'
  148 |  amqp_exchange_exception_class_entry = PHP5to7_zend_register_internal_class_ex(&ce, amqp_exception_class_entry);
      |                                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/tmp/pear/temp/amqp/php7_support.h:63:114: error: expected ')' before 'TSRMLS_CC'
   63 | #define PHP5to7_zend_register_internal_class_ex(ce, parent_ce) zend_register_internal_class_ex((ce), (parent_ce) TSRMLS_CC)
      |                                                                                                                  ^~~~~~~~~
/tmp/pear/temp/amqp/amqp.c:151:37: note: in expansion of macro 'PHP5to7_zend_register_internal_class_ex'
  151 |  amqp_value_exception_class_entry = PHP5to7_zend_register_internal_class_ex(&ce, amqp_exception_class_entry);
      |                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/tmp/pear/temp/amqp/amqp.c: At top level:
/tmp/pear/temp/amqp/amqp.c:242:147: error: expected ';', ',' or ')' before 'TSRMLS_DC'
  242 | int php_amqp_error(amqp_rpc_reply_t reply, char **message, amqp_connection_resource *connection_resource, amqp_channel_resource *channel_resource TSRMLS_DC)
      |                                                                                                                                                   ^~~~~~~~~
/tmp/pear/temp/amqp/amqp.c:247:176: error: expected ';', ',' or ')' before 'TSRMLS_DC'
  247 | int php_amqp_error_advanced(amqp_rpc_reply_t reply, char **message, amqp_connection_resource *connection_resource, amqp_channel_resource *channel_resource, int fail_on_errors TSRMLS_DC)
      |                                                                                                                                                                                ^~~~~~~~~
/tmp/pear/temp/amqp/amqp.c:294:97: error: expected ';', ',' or ')' before 'TSRMLS_DC'
  294 | void php_amqp_zend_throw_exception_short(amqp_rpc_reply_t reply, zend_class_entry *exception_ce TSRMLS_DC) {
      |                                                                                                 ^~~~~~~~~
/tmp/pear/temp/amqp/amqp.c:298:144: error: expected ';', ',' or ')' before 'TSRMLS_DC'
  298 | void php_amqp_zend_throw_exception(amqp_rpc_reply_t reply, zend_class_entry *exception_ce, const char *message, PHP5to7_param_long_type_t code TSRMLS_DC)
      |                                                                                                                                                ^~~~~~~~~
make: *** [Makefile:209: amqp.lo] Error 1
ERROR: `make' failed
The command '/bin/sh -c install-php-extensions amqp' returned a non-zero code: 1

install specific version

hi, is there anything I missed, that gives me the chance to install a specific version of an extension ???

thanks

Remove dev packages after building

This script installs a lot of packages that are needed to build the php extensions. It would be nice that it also removes the ones that are not needed afterwards in order to keep layers small.

These are mostly the ones that end with *-dev.

Alpine support

Just a quick question, rather than a trouble ticket. Are there any plans to support Alpine distros in the future? The biggest difference has to do with installing prerequisites - it uses apk add instead of apt-get install, basically.

Support PHP 8

PHP 8 Images does not contain pecl anymore. Any installation of xdebug, redis will fail

Remove "no longer required" packages?

After I used this script like install-php-extensions --cleanup pdo_pgsql soap intl I saw a message in a console saying:

The following packages were automatically installed and are no longer required:
  icu-devtools libpq5
Use 'apt autoremove' to remove them.

How about the --cleanup parameter will also run apt autoremove command to shrink the final image's size?

Add support for SVG

The support for SVG in imagick by adding "libmagickcore-dev" as dependancy

Support for LDAP on linux/386

In order to close this ticket I've been trying to build this Dockerfile on linux/386 using buildx.

Unfortunately, my script errors out on the LDAP package for PHP7.4:

#53 108.9 configure: error: Cannot find ldap libraries in /usr/lib/i686-linux-gnu.

I was hoping you know if this can be fixed, or if there's something I can do to help.

I believe I was thorough with sharing info but please let me know if you need additional details.

Install broken in 5.5 Alpine

I know alpine is not officially supported for version 5.5 (as stated in the README)...

Anyway it used to work perfectly, so I suspect some recent changes may have introduced the bug.

I ran into the problem recently and found the problem, hence possibly the workaround 😺

First, here are the environment informations:

/var/www/html # php -v
PHP 5.5.38 (cli) (built: Aug 10 2016 21:15:09) 
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2015 Zend Technologies
/var/www/html # cat /etc/os-release 
NAME="Alpine Linux"
ID=alpine
VERSION_ID=3.4.0
PRETTY_NAME="Alpine Linux v3.4"
HOME_URL="http://alpinelinux.org"
BUG_REPORT_URL="http://bugs.alpinelinux.org"
/var/www/html#

First try:

/var/www/html # install-php-extensions pdo_mysql
fetch http://dl-cdn.alpinelinux.org/alpine/v3.4/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.4/community/x86_64/APKINDEX.tar.gz
v3.4.6-316-g63ea6d0 [http://dl-cdn.alpinelinux.org/alpine/v3.4/main]
v3.4.6-160-g14ad2a3 [http://dl-cdn.alpinelinux.org/alpine/v3.4/community]
OK: 5990 distinct packages available
### INSTALLING REQUIRED PACKAGES ###
# Packages to be kept after installation: 
# Packages to be used only for installation: m4 perl autoconf libmagic file libgcc libstdc++ binutils-libs binutils gmp isl libgomp libatomic pkgconf pkgconfig mpfr3 mpc1 gcc musl-dev libc-dev g++ make re2c
(1/25) Upgrading musl (1.1.14-r11 -> 1.1.14-r16)
(2/25) Installing m4 (1.4.17-r1)
(3/25) Installing perl (5.22.3-r0)
(4/25) Installing autoconf (2.69-r0)
(5/25) Installing binutils-libs (2.26-r1)
(6/25) Installing binutils (2.26-r1)
(7/25) Installing libmagic (5.27-r0)
(8/25) Installing file (5.27-r0)
(9/25) Installing libgcc (5.3.0-r0)
(10/25) Installing libstdc++ (5.3.0-r0)
(11/25) Installing gmp (6.1.0-r0)
(12/25) Installing isl (0.14.1-r0)
(13/25) Installing libgomp (5.3.0-r0)
(14/25) Installing libatomic (5.3.0-r0)
(15/25) Installing pkgconf (0.9.12-r0)
(16/25) Installing pkgconfig (0.25-r1)
(17/25) Installing mpfr3 (3.1.2-r0)
(18/25) Installing mpc1 (1.0.3-r0)
(19/25) Installing gcc (5.3.0-r0)
(20/25) Installing musl-dev (1.1.14-r16)
(21/25) Installing libc-dev (0.7-r0)
(22/25) Installing g++ (5.3.0-r0)
(23/25) Upgrading musl-utils (1.1.14-r11 -> 1.1.14-r16)
(24/25) Installing make (4.1-r1)
(25/25) Installing re2c (0.14.3-r0)
Executing busybox-1.24.2-r9.trigger
OK: 217 MiB in 48 packages
### INSTALLING BUNDLED MODULE pdo_mysql ###
/usr/local/bin/install-php-extensions: line 1633: nproc: not found
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 fileinfo filter ftp gd gettext gmp hash iconv imap interbase intl json ldap mbstring mcrypt mssql mysql 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 recode reflection session shmop simplexml snmp soap sockets spl standard sybase_ct sysvmsg sysvsem sysvshm tidy tokenizer wddx xml xmlreader xmlrpc xmlwriter xsl zip
/var/www/html # 

Fail! seems the nproc binary is missing...

A quick look at the Alpine Linux database tells us we need the coreutils package.

Let's install the missing package...

/var/www/html # apk add coreutils
(1/3) Installing libattr (2.4.47-r4)
(2/3) Installing libacl (2.2.52-r2)
(3/3) Installing coreutils (8.25-r0)
Executing busybox-1.24.2-r9.trigger
OK: 222 MiB in 51 packages

... and give it a try again

/var/www/html # install-php-extensions pdo_mysql
fetch http://dl-cdn.alpinelinux.org/alpine/v3.4/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.4/community/x86_64/APKINDEX.tar.gz
v3.4.6-316-g63ea6d0 [http://dl-cdn.alpinelinux.org/alpine/v3.4/main]
v3.4.6-160-g14ad2a3 [http://dl-cdn.alpinelinux.org/alpine/v3.4/community]
OK: 5988 distinct packages available
### INSTALLING BUNDLED MODULE pdo_mysql ###
fetch http://dl-cdn.alpinelinux.org/alpine/v3.4/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.4/community/x86_64/APKINDEX.tar.gz
(1/1) Installing .phpize-deps (0)
OK: 222 MiB in 52 packages
+ cd /usr/src/php/ext/pdo_mysql
+ phpize
Configuring for:
PHP Api Version:         20121113
Zend Module Api No:      20121212
Zend Extension Api No:   220121212
+ ./configure
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-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-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-20121212
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.14.3 (ok)
checking for gawk... no
checking for nawk... no
checking for awk... awk
checking if awk is broken... no
checking for MySQL support for PDO... yes, shared
checking for the location of libz... no
checking for PDO includes... checking for PDO includes... /usr/local/include/php/ext
checking for ld used by cc... /usr/x86_64-alpine-linux-musl/bin/ld
checking if the linker (/usr/x86_64-alpine-linux-musl/bin/ld) is GNU ld... yes
checking for /usr/x86_64-alpine-linux-musl/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 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 dlfcn.h usability... yes
checking dlfcn.h presence... yes
checking for dlfcn.h... yes
checking the maximum length of command line arguments... 98304
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/x86_64-alpine-linux-musl/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
(...)

It works!

Configure GD on buster

To configure GD on Debian Buster or PHP 7.4 the arguments should be different, see https://github.com/php/php-src/blob/07fc0764d1ca33bc9a7e5ccb0506f835827c402a/UPGRADING#L746

The arguments on

docker-php-ext-configure gd --with-gd --with-webp-dir --with-jpeg-dir --with-png-dir --with-zlib-dir --with-xpm-dir --with-freetype-dir --enable-gd-native-ttf
and
docker-php-ext-configure gd --with-gd --with-webp-dir --with-jpeg-dir --with-png-dir --with-zlib-dir --with-xpm-dir --with-freetype-dir
should be
docker-php-ext-configure gd --enable-gd --with-webp --with-jpeg --with-xpm --with-freetype

Tag releases on master branch

It would be great to be able to use a specific version of the script when building docker images rather than just a general 'latest'. Moving forward this might also be helpful to maintainers in being able to remove support for older php versions and distros

Cleanup does not leave already installed packages

As far as I can see cleanup (run by default since f164c69) does not leave already installed packages, but please correct me if I'm wrong.
This means that the following will not work

RUN apt-get install -y --no-install-recommends \
    a-package-i-need-later-on-and-is-needed-by-an-extension
RUN install-php-extensions an-extension
RUN something-that-needs-a-package-i-need-later-on-and-is-needed-by-an-extension

Shouldn't just the delta of what was on the system and what is later on on the system be cleaned?

Installing zip extension throws deprecated warning

WARNING: Use of bundled libzip is deprecated and will be removed.
configure: WARNING: Some features such as encryption and bzip2 are not available.
configure: WARNING: Use system library and --with-libzip is recommended.

I created a pull request that might resolve the issue
#22

'Unzip' command unknown - when installing 'zip' extension

On my dev docker image I install the following php extensions (simplified Dockerfile):

FROM php:7.2-fpm
ADD https://raw.githubusercontent.com/mlocati/docker-php-extension-installer/master/install-php-extensions /usr/local/bin/
RUN chmod uga+x /usr/local/bin/install-php-extensions \
    && sync \
    && install-php-extensions --cleanup \
    gd exif imagick zip mcrypt ldap intl gettext odbc pdo_mysql pdo_pgsql 
    pdo_sqlsrv sqlsrv redis opcache apcu imap bcmath xdebug

If I create e new concrete5 project inside the container with:
"docker-compose exec php72-fpm bash -c "composer create-project -n concrete5/composer ."

Composer/PHP shows the following warning. See As there is no 'unzip' command installed zip files .... (From line 2:)

Installing concrete5/composer (v1.1.9)
As there is no 'unzip' command installed zip files are being unpacked using the PHP zip extension.
This may cause invalid reports of corrupted archives. Besides, any UNIX permissions (e.g. executable) defined in the archives will be lost.
Installing 'unzip' may remediate them.
  - Installing concrete5/composer (v1.1.9): Downloading (100%)         
Created project in .
Loading composer repositories with package information
Updating dependencies (including require-dev)

LDAP extension installation failing

After trying it manually, I now get the same error with this tool. Below see the log and Dockerfile. The base image I am using is based on php:7.4-apache-buster.

FROM martinhelmich/typo3:10.4

ADD https://raw.githubusercontent.com/mlocati/docker-php-extension-installer/master/install-php-extensions /usr/local/bin/

RUN chmod uga+x /usr/local/bin/install-php-extensions && sync && \
    install-php-extensions ldap
> docker build --no-cache -f typo3-ldap.dockerfile .
Sending build context to Docker daemon  2.048kB
Step 1/3 : FROM martinhelmich/typo3:10.4
 ---> b2c3ff908a23
Step 2/3 : ADD https://raw.githubusercontent.com/mlocati/docker-php-extension-installer/master/install-php-extensions /usr/local/bin/
Downloading  53.83kB
 ---> 942c761860ed
Step 3/3 : RUN chmod uga+x /usr/local/bin/install-php-extensions && sync &&     install-php-extensions ldap
 ---> Running in 7af7066441a0
Get:1 http://deb.debian.org/debian buster InRelease [122 kB]
Get:2 http://security.debian.org/debian-security buster/updates InRelease [65.4 kB]
Get:3 http://deb.debian.org/debian buster-updates InRelease [49.3 kB]
Get:4 http://security.debian.org/debian-security buster/updates/main amd64 Packages [189 kB]
Get:5 http://deb.debian.org/debian buster/main amd64 Packages [7907 kB]
Get:6 http://deb.debian.org/debian buster-updates/main amd64 Packages [7380 B]
Fetched 8339 kB in 2s (3466 kB/s)
Reading package lists...
### INSTALLING REQUIRED PACKAGES ###
# Packages to be kept after installation: 
# Packages to be used only for installation: libldap2-dev
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package libldap2-dev:amd64.
(Reading database ... 14450 files and directories currently installed.)
Preparing to unpack .../libldap2-dev_2.4.47+dfsg-3+deb10u1_amd64.deb ...
Unpacking libldap2-dev:amd64 (2.4.47+dfsg-3+deb10u1) ...
Setting up libldap2-dev:amd64 (2.4.47+dfsg-3+deb10u1) ...
tar (child): /usr/src/php.tar.xz: Cannot open: No such file or directory
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now
The command '/bin/sh -c chmod uga+x /usr/local/bin/install-php-extensions && sync &&     install-php-extensions ldap' returned a non-zero code: 2

Installing specific extension version does not work

install-php-extensions xdebug-2.9.8

Output:

#9 61.89 configuration option "php_ini" is not set to php.ini location
#9 61.89 You should add "zend_extension=/usr/local/lib/php/extensions/no-debug-non-zts-20190902/xdebug.so" to php.ini
#9 61.92 error: 'xdebug-2.9.8' does not exist

Error configuring GD: unrecognized options

Got stuck at this command when doing docker build:

docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/

This is the error i got:

configure: error: unrecognized options: --with-freetype-dir, --with-jpeg-dir

I'm using the php:7.4.3-fpm-buster image.

Couldn't find pcre.h

I get the following error when trying to install the oauth extension on php:7.4-fpm-alpine:

### INSTALLING PECL MODULE oauth ###
downloading oauth-2.0.5.tgz ...
Starting to download oauth-2.0.5.tgz (49,641 bytes)
... (omitted for brevity)
configure: error: Couldn't find pcre.h, try installing the libpcre development/headers package

Workaround: add pcre-dev package

pdo_firebird installation fails

Hello
I'm trying to install pdo_firebird extension to php:7.4-fpm-alpine image... And installation fails with error of missing some libs
My Docker file for build is:

FROM php:7.4-fpm-alpine
RUN docker-php-ext-install pdo_firebird && rm -rf /tmp/* /var/cache/apk/*

Process log:

Step 1/2 : FROM php:7.4-fpm-alpine
 ---> d05062ed9212
Step 2/2 : RUN docker-php-ext-install pdo_firebird && rm -rf /tmp/* /var/cache/apk/*
 ---> Running in 68959c3f3ab9
fetch http://dl-cdn.alpinelinux.org/alpine/v3.12/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.12/community/x86_64/APKINDEX.tar.gz
(1/26) Installing m4 (1.4.18-r1)
(2/26) Installing libbz2 (1.0.8-r1)
(3/26) Installing perl (5.30.3-r0)
(4/26) Installing autoconf (2.69-r2)
(5/26) Installing pkgconf (1.7.2-r0)
(6/26) Installing dpkg-dev (1.20.0-r0)
(7/26) Installing dpkg (1.20.0-r0)
(8/26) Installing libmagic (5.38-r0)
(9/26) Installing file (5.38-r0)
(10/26) Installing libgcc (9.3.0-r2)
(11/26) Installing libstdc++ (9.3.0-r2)
(12/26) Installing binutils (2.34-r1)
(13/26) Installing gmp (6.2.0-r0)
(14/26) Installing isl (0.18-r0)
(15/26) Installing libgomp (9.3.0-r2)
(16/26) Installing libatomic (9.3.0-r2)
(17/26) Installing libgphobos (9.3.0-r2)
(18/26) Installing mpfr4 (4.0.2-r4)
(19/26) Installing mpc1 (1.1.0-r1)
(20/26) Installing gcc (9.3.0-r2)
(21/26) Installing musl-dev (1.1.24-r9)
(22/26) Installing libc-dev (0.7.2-r3)
(23/26) Installing g++ (9.3.0-r2)
(24/26) Installing make (4.3-r0)
(25/26) Installing re2c (1.3-r1)
(26/26) Installing .phpize-deps (20200904.070059)
Executing busybox-1.31.1-r16.trigger
OK: 255 MiB in 57 packages
Configuring for:
PHP Api Version:         20190902
Zend Module Api No:      20190902
Zend Extension Api No:   320190902
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 pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
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 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-musl
checking host system type... x86_64-pc-linux-musl
checking target system type... x86_64-pc-linux-musl
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-20190902
checking for PHP installed headers prefix... /usr/local/include/php
checking if debug is enabled... no
checking if zts is enabled... no
checking for gawk... no
checking for nawk... no
checking for awk... awk
checking if awk is broken... no
checking for Firebird support for PDO... yes, shared
checking for fb_config... no
checking for isc_detach_database in -lfbclient... no
checking for isc_detach_database in -lgds... no
checking for isc_detach_database in -lib_util... no
configure: error: libfbclient, libgds or libib_util not found! Check config.log for more information.

Please help me to solve this problem.

Support for gnupg extension

FROM php:7.4-cli-alpine
COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/bin/install-php-extensions
RUN install-php-extensions gnupg
STEP 3: RUN install-php-extensions gnupg
Updating channel "pecl.php.net"
Channel "pecl.php.net" is up to date
fetch http://dl-cdn.alpinelinux.org/alpine/v3.12/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.12/community/x86_64/APKINDEX.tar.gz
v3.12.1-47-g77e786238c [http://dl-cdn.alpinelinux.org/alpine/v3.12/main]
v3.12.1-63-gbb5c05cff7 [http://dl-cdn.alpinelinux.org/alpine/v3.12/community]
OK: 12746 distinct packages available
### INSTALLING REQUIRED PACKAGES ###
# Packages to be kept after installation:
# Packages to be used only for installation: m4 libbz2 perl autoconf dpkg pkgconf dpkg-dev libmagic file libgcc libstdc++ binutils gmp isl libgomp libatomic libgphobos mpfr4 mpc1 gcc musl-dev libc-dev g++ make re2c
(1/26) Upgrading musl (1.1.24-r9 -> 1.1.24-r10)
(2/26) Installing m4 (1.4.18-r1)
(3/26) Installing libbz2 (1.0.8-r1)
(4/26) Installing perl (5.30.3-r0)
(5/26) Installing autoconf (2.69-r2)
(6/26) Installing libgcc (9.3.0-r2)
(7/26) Installing libstdc++ (9.3.0-r2)
(8/26) Installing binutils (2.34-r1)
(9/26) Installing dpkg (1.20.0-r0)
(10/26) Installing pkgconf (1.7.2-r0)
(11/26) Installing dpkg-dev (1.20.0-r0)
(12/26) Installing libmagic (5.38-r0)
(13/26) Installing file (5.38-r0)
(14/26) Installing gmp (6.2.0-r0)
(15/26) Installing isl (0.18-r0)
(16/26) Installing libgomp (9.3.0-r2)
(17/26) Installing libatomic (9.3.0-r2)
(18/26) Installing libgphobos (9.3.0-r2)
(19/26) Installing mpfr4 (4.0.2-r4)
(20/26) Installing mpc1 (1.1.0-r1)
(21/26) Installing gcc (9.3.0-r2)
(22/26) Installing musl-dev (1.1.24-r10)
(23/26) Installing libc-dev (0.7.2-r3)
(24/26) Installing g++ (9.3.0-r2)
(25/26) Installing make (4.3-r0)
(26/26) Installing re2c (1.3-r1)
Executing busybox-1.31.1-r19.trigger
OK: 255 MiB in 56 packages
### INSTALLING PECL MODULE gnupg ###
downloading gnupg-1.4.0.tgz ...
Starting to download gnupg-1.4.0.tgz (28,349 bytes)
.....done: 28,349 bytes
6 source files, building
running: phpize
Configuring for:
PHP Api Version:         20190902
Zend Module Api No:      20190902
Zend Extension Api No:   320190902
building in /tmp/pear/temp/pear-build-defaultuseraJIbak/gnupg-1.4.0
running: /tmp/pear/temp/gnupg/configure --with-php-config=/usr/local/bin/php-config
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 pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
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 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-musl
checking host system type... x86_64-pc-linux-musl
checking target system type... x86_64-pc-linux-musl
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-20190902
checking for PHP installed headers prefix... /usr/local/include/php
checking if debug is enabled... no
checking if zts is enabled... no
checking for gawk... no
checking for nawk... no
checking for awk... awk
checking if awk is broken... no
checking for gnupg support... yes, shared
checking for gnupg files in default path... not found
configure: error: Please reinstall the gpgme distribution
ERROR: `/tmp/pear/temp/gnupg/configure --with-php-config=/usr/local/bin/php-config' failed
Error: error building at STEP "RUN install-php-extensions gnupg": error while running runtime: exit status 1

Also tested on tag php:7.4-cli (debian buster).

gmp and pdo_dblib not build on arm arch because function getTargetTriplet not use

Hi,

the extension gmp and pdo_dblib not build on arm arch.

Example error message: configure: error: Could not find /usr/lib/libsybdb.a|so

In Line 1070 and 1116 are not use function getTargetTriplet from Line 893. There is x86_64-linux-gnu used.

With sed -i "s|\/x86_64-linux-gnu\/|\/$\(getTargetTriplet\)\/|g" install-php-extensions in my Dockerfile on RaspberryPi it build successful.

(I switched my dockerfile to php-extension-installer yesterday and I am excited. Makes a lot of things easier. Thanks!)

Running install-php-extensions more than once

I am doing something like this:

FROM php:7.0.12-fpm

COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/bin/

ARG WITH_XDEBUG

RUN install-php-extensions \
    gd \
    opcache \
    pdo_mysql \
    redis \
    ${WITH_XDEBUG:+xdebug}

... and building two images, one with and one without Xdebug. I just realized that this is probably not optimal ITO layer caching, as the work of installing 4 of the 5 extensions is repeated.

Would it make sense to run install-php-extensions a second time? Is this normal/safe, and would any expensive work be repeated this way?

It would look like this:

FROM php:7.0.12-fpm

COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/bin/

RUN install-php-extensions \
    gd \
    opcache \
    pdo_mysql \
    redis

ARG WITH_XDEBUG=false

RUN if [ $WITH_XDEBUG = "true" ]; then install-php-extensions xdebug; fi

install redis error

when i tried install-php-extensions redis .it show me 'ERROR: unable to unpack /tmp/pear/download/redis-5.2.2.tgz' like that
image

how can i install redis expansion with install-php-extensions correctly?

my docker images base on php:7.2-fpm

Failed to fetch http://deb.debian.org/debian/dists/jessie-updates/InRelease

Hi! I'm using your code snippet to install pspell onto my docker container (php:7.1-apache-jessie), and I'm getting the following error:

W: Failed to fetch http://deb.debian.org/debian/dists/jessie-updates/InRelease Unable to find expected entry 'main/binary-amd64/Packages' in Release file (Wrong sources.list entry or malformed file)

E: Some index files failed to download. They have been ignored, or old ones used instead.
The command '/bin/sh -c chmod uga+x /usr/local/bin/install-php-extensions && install-php-extensions pspell' returned a non-zero code: 100

Maybe this has something to do with this: https://lists.debian.org/debian-devel-announce/2019/03/msg00006.html?

Appreciate your help!

missing igbinary support for memcached

$ docker run --rm -ti php:8.0-rc-fpm-alpine sh
#wget -O /usr/local/bin/install-php-extensions https://raw.githubusercontent.com/mlocati/docker-php-extension-installer/master/install-php-extensions
# chmod u+x /usr/local/bin/pickle /usr/local/bin/install-php-extensions
# install-php-extensions igbinary memcached
...
# php --ri memcached | grep igb
igbinary support => no

the script contains just a placeholder for detecting igbinary, the compilation option is not added
https://github.com/mlocati/docker-php-extension-installer/blob/master/install-php-extensions#L1136

Plans to merge it with Official Docker image for PHP?

That is an awesome library, man!

It will be a great idea to merge this with the Official Docker image for PHP, because it's frustating to install the PHP extensions in Docker with only docker-php-ext-install and a lot of bugs or missing apt packages.

Do you have any plan to propose a merge?

Support for Maxmind

Hello,

Would it be possible to support Maxmind from https://github.com/maxmind/MaxMind-DB-Reader-php (the Optional C Extension) which need to be manually build to work ?

Actually I'm doing this inside my container and I think it would fit with how the installer works regarding "install-php-extensions" file.

RUN echo "deb http://deb.debian.org/debian/ buster main contrib non-free" >> /etc/apt/sources.list
RUN apt-get update &&
apt-get -y --force-yes install libmaxminddb0 libmaxminddb-dev mmdb-bin geoipupdate
ADD 35-maxminddb.ini /etc/php/7.3/fpm/conf.d/35-maxminddb.ini
ADD GeoIP.conf /etc/GeoIP.conf
RUN cd /tmp && git clone https://github.com/maxmind/MaxMind-DB-Reader-php.git &&
cd /tmp/MaxMind-DB-Reader-php/ext && phpize && ./configure -q && make -s && make -s install &&
geoipupdate

Thanks for your work!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.