Giter VIP home page Giter VIP logo

Comments (44)

hp9390 avatar hp9390 commented on May 18, 2024 187

An almost complete list:

RUN apt update
RUN apt upgrade -y
RUN apt install -y apt-utils
RUN a2enmod rewrite
RUN apt install -y libmcrypt-dev
RUN docker-php-ext-install mcrypt
RUN apt install -y libicu-dev
RUN docker-php-ext-install -j$(nproc) intl
RUN apt-get install -y libfreetype6-dev libjpeg62-turbo-dev libpng12-dev
RUN docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ 
RUN docker-php-ext-install -j$(nproc) gd    
RUN apt install -y php-apc    
RUN apt install -y libxml2-dev 
RUN apt install -y libldb-dev
RUN apt install -y libldap2-dev 
RUN apt install -y libxml2-dev
RUN apt install -y libssl-dev
RUN apt install -y libxslt-dev
RUN apt install -y libpq-dev
RUN apt install -y postgresql-client
RUN apt install -y mysql-client 
RUN apt install -y libsqlite3-dev
RUN apt install -y libsqlite3-0
RUN apt install -y libc-client-dev
RUN apt install -y libkrb5-dev
RUN apt install -y curl
RUN apt install -y libcurl3
RUN apt install -y libcurl3-dev
RUN apt install -y firebird-dev
RUN apt-get install -y libpspell-dev
RUN apt-get install -y aspell-en
RUN apt-get install -y aspell-de  
RUN apt install -y libtidy-dev
RUN apt install -y libsnmp-dev
RUN apt install -y librecode0
RUN apt install -y librecode-dev
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin/ --filename=composer
#RUN pecl install apc
RUN docker-php-ext-install opcache
RUN yes | pecl install xdebug \
    && 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 docker-php-ext-install soap
RUN docker-php-ext-install ftp
RUN docker-php-ext-install xsl
RUN docker-php-ext-install bcmath
RUN docker-php-ext-install calendar
RUN docker-php-ext-install ctype
RUN docker-php-ext-install dba
RUN docker-php-ext-install dom
RUN docker-php-ext-install zip
RUN docker-php-ext-install session
RUN docker-php-ext-configure ldap --with-libdir=lib/x86_64-linux-gnu
RUN docker-php-ext-install ldap
RUN docker-php-ext-install json
RUN docker-php-ext-install hash
RUN docker-php-ext-install sockets
RUN docker-php-ext-install pdo
RUN docker-php-ext-install mbstring
RUN docker-php-ext-install tokenizer
RUN docker-php-ext-install pgsql
RUN docker-php-ext-install pdo_pgsql
RUN docker-php-ext-install pdo_mysql 
RUN docker-php-ext-install pdo_sqlite
RUN docker-php-ext-install intl
RUN docker-php-ext-install mcrypt
RUN docker-php-ext-install mysqli
RUN docker-php-ext-configure imap --with-kerberos --with-imap-ssl
RUN docker-php-ext-install imap
RUN docker-php-ext-install gd
RUN docker-php-ext-install curl
RUN docker-php-ext-install exif
RUN docker-php-ext-install fileinfo
RUN docker-php-ext-install gettext
#RUN apt install -y libgmp-dev # idk
#RUN docker-php-ext-install gmp # idk
RUN docker-php-ext-install iconv
RUN docker-php-ext-install interbase
RUN docker-php-ext-install pdo_firebird
RUN docker-php-ext-install opcache
#RUN docker-php-ext-install oci8 # idk
#RUN docker-php-ext-install odbc # idk
RUN docker-php-ext-install pcntl
#RUN apt install -y freetds-dev # idk
#RUN docker-php-ext-install pdo_dblib  # idk
#RUN docker-php-ext-install pdo_oci # idk
#RUN docker-php-ext-install pdo_odbc # idk
RUN docker-php-ext-install phar
RUN docker-php-ext-install posix
RUN docker-php-ext-install pspell
#RUN apt install -y libreadline-dev # idk
#RUN docker-php-ext-install readline # idk
RUN docker-php-ext-install recode
RUN docker-php-ext-install shmop
RUN docker-php-ext-install simplexml
RUN docker-php-ext-install snmp
RUN docker-php-ext-install sysvmsg
RUN docker-php-ext-install sysvsem
RUN docker-php-ext-install sysvshm
RUN docker-php-ext-install tidy
RUN docker-php-ext-install wddx
RUN docker-php-ext-install xml
#RUN apt install -y libxml2-dev # idk
#RUN docker-php-ext-install xmlreader # idk
RUN docker-php-ext-install xmlrpc
RUN docker-php-ext-install xmlwriter             
# idk bz2 enchant 

Off topic, but another tip:

If you, like me, need to run ie a framework and want to access your source directory from within your host system (lets say in your IDE for dev purposes), add this in your Dockerfile:
RUN useradd user
Then, you will need to add a config file for your Apache. My preferred way of doing this is mounting it. Anyway, the directory is /etc/apache2/conf-enabled.
In your config you need to add:

User user
Group user

Of course, you will need to replace user with your local user.

Maybe someone can figure out a way to make those missing extensions work.

from php.

MrTrick avatar MrTrick commented on May 18, 2024 176

After trawling through /usr/src/php/ext/ldap/configure and tracing back from the error message, I eventually figured out that the LDAP extension can be installed with the following commands;

 # Install needed php extensions: ldap
RUN \
    apt-get update && \
    apt-get install libldap2-dev -y && \
    rm -rf /var/lib/apt/lists/* && \
    docker-php-ext-configure ldap --with-libdir=lib/x86_64-linux-gnu/ && \
    docker-php-ext-install ldap

Leaving this issue open because I think the wider problem is still relevant.

from php.

carnage avatar carnage commented on May 18, 2024 53

(Incomplete) List of extensions and the debian packages they require to build:

ldap: libldap2-dev (configure: --with-libdir=lib/x86_64-linux-gnu/)
soap: libxml2-dev
mcrypt: libmcrypt-dev
ftp: libssl-dev
intl: libicu-dev
xsl: libxslt-dev
imap: libc-client-dev libkrb5-dev (configure: --with-kerberos --with-imap-ssl)

from php.

devurandom avatar devurandom commented on May 18, 2024 26

I agree with the original poster that docker-php-ext-install should by default do the installation of dependencies and the correct configure options automatically. I am not a PHP maintainer / packager. I have no idea what dependencies each extension has. I can peek into the Debian package database or into the Gentoo ebuild, but that is not really convenient.

I suggest that the docker image includes a file which maps extensions to their dependencies (Debian package names) and possibly the required configure flags. The docker-php-ext-install could use that information to automatically install and configure. For users who want more control you could add a --manual flag, which disables that and just does what the script does currently.

ATM the added value above the Debian provided PHP packages seems very small (unless you need a very specific version of PHP, which I don't).

from php.

francislavoie avatar francislavoie commented on May 18, 2024 21

@hp9390 This list is great, but what about for fpm-alpine? We need a list for alpine as well.

from php.

SanderSander avatar SanderSander commented on May 18, 2024 21

For ldap on alpine

FROM php:alpine

RUN apk update && \
    apk add --no-cache --virtual .build-deps $PHPIZE_DEPS icu-dev openldap-dev && \
    docker-php-ext-install ldap && \
    apk del .build-deps && \
    rm -rf /tmp/* /var/cache/apk/*

from php.

mlocati avatar mlocati commented on May 18, 2024 14

@jungleran Thanks for the tips: I just added support for mcrypt under PHP 7.2 in my install-php-extensions script, so that you can install it simply with one line:

install-php-extensions mcrypt

from php.

schmunk42 avatar schmunk42 commented on May 18, 2024 9

You can get at least some hints from apt-cache which packages are needed for building an extension.
I've just created a debian-based image for that, improvements/ideas welcome...

Examples:

$ docker run schmunk42/apt apt-cache depends php5-xsl   
php5-xsl
  Depends: libc6
  Depends: libxml2
  Depends: libxslt1.1
  Depends: <phpapi-20131226>
    php5-common
  Depends: php5-common
  Depends: ucf
$ docker run schmunk42/apt apt-cache depends php5-ldap
php5-ldap
  Depends: libc6
  Depends: libldap-2.4-2
  Depends: libsasl2-2
  Depends: <phpapi-20131226>
    php5-common
  Depends: php5-common
  Depends: ucf

from php.

skroczek avatar skroczek commented on May 18, 2024 9

@rufinus @SanderSander
An additional suggest because I got the error:

 PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20160303/ldap.so' - Error loading shared library libldap-2.4.so.2: No such file or directory (needed by /usr/local/lib/php/extensions/no-debug-non-zts-20160303/ldap.so) in Unknown on line 0

I have to add libldap to the persistent-deps

RUN apk add --no-cache --virtual .persistent-deps \
		libldap
RUN apk update && \
         apk add --no-cache --virtual .build-deps $PHPIZE_DEPS openldap-dev && \
         docker-php-ext-install ldap && \
         apk del .build-deps

from php.

tianon avatar tianon commented on May 18, 2024 7

I personally find necessary dependencies for PHP extensions the same way I do for any random compiled software I dockerize. The rough process is as follows:

  1. write the Dockerfile such that it downloads, extracts, and attempts to compile the software
  2. when it throws an error, it usually includes the name of a library or header file that's missing:
  • if Alpine, I use https://pkgs.alpinelinux.org/contents to figure out which package contains the file I need (or look for a -dev package of the error message's referenced library)
  • if Debian, I use https://packages.debian.org/file:XYZ.h for searching the archive for packages which provide the files I need (or look for a -dev package of the error message's referenced library)
  1. add the appropriate packages to the Dockerfile, rinse and repeat until the build completes

Sometimes I'll look at the source of the relevant Debian package for clues (from Build-Depends in https://sources.debian.org/src/php7.0/7.0.26-1/debian/control/, for example) or Alpine (from makedepends in https://git.alpinelinux.org/cgit/aports/tree/community/php7/APKBUILD?id=d0ca197f031f96d4664cafaa618aeccf94640a1e, for example).

Regardless, I think it's a huge undertaking to compile a full list of all possible combinations of core extension's dependencies per-PHP-version-per-distro-per-distro-release, and not one the maintainers of this image are willing to undertake. At this point, there are several other official images which are FROM php which install various extensions (https://github.com/docker-library/wordpress/blob/1b48b4bccd7adb0f7ea1431c7b470a40e186f3da/Dockerfile-debian.template#L3-L15, for example), not to mention the wealth of community-maintained images which are also FROM php if someone wanted to use them as a starting point to try and compile such a list as a separate project.

As such, I'm closing this, but appreciate the discussion (and think it serves as a good reference and/or starting point for travelers from the future).

For further discussion of this topic, I'd recommend posting to the Docker Community Forums, the Docker Community Slack, or Stack Overflow in order to capture a wider user base. Thanks!

from php.

tianon avatar tianon commented on May 18, 2024 7

Those still following along here might want to check out https://github.com/mlocati/docker-php-extension-installer from @mlocati. 👍

from php.

waspinator avatar waspinator commented on May 18, 2024 6

installing soap:

RUN apt-get update -y \
  && apt-get install -y \
    libxml2-dev \
    php-soap \
  && apt-get clean -y \
  && docker-php-ext-install soap	

from php.

mlocati avatar mlocati commented on May 18, 2024 4

@ustccq as stated above, you can use my install-php-extensions script to easily install the ldap PHP extension (as well as many other extensions), both on Alpine and Debian based Docker images.

from php.

rufinus avatar rufinus commented on May 18, 2024 3

for ldap i use this (with 7.2)

RUN  apk add --no-cache --virtual .build-deps $PHPIZE_DEPS icu-dev openldap-dev && \
    docker-php-ext-install ldap  && \
    docker-php-ext-enable ldap && \
    apk del .build-deps

from php.

rufinus avatar rufinus commented on May 18, 2024 2

@SanderSander :

May i suggest:

RUN apk update && \
         apk add --no-cache --virtual .build-deps $PHPIZE_DEPS openldap-dev && \
         docker-php-ext-install ldap && \
         apk del .build-deps && \
         rm -rf /tmp/* /var/cache/apk/*

from php.

ranqiangjun avatar ranqiangjun commented on May 18, 2024 2

FYI, for mcrypt, php 7.2

RUN apt install -y libmcrypt-dev
RUN docker-php-ext-install mcrypt

The mycrypt extension is not provided with the PHP source since 7.2. The way above is not working anymore.

Updated:

RUN apt install libmcrypt-dev -y \
    && pecl install mcrypt-1.0.1 \
    && docker-php-ext-enable mcrypt

from php.

cg-d avatar cg-d commented on May 18, 2024 1

I had an analogous problem when trying to install soap. I had extend my Dockerfile with

apt-get install -y libxml2-dev --no-install-recommends

I did not test yet whether installing one or some of ext-install options xml, xmlreader, xmlrpc, xmlwriter, or xsl would do the trick. And if so in which order?

from php.

 avatar commented on May 18, 2024 1

@carnage That list should definitely become part of this repository. It's very useful and could in the future be use to automate this.

Further, php-ext-install could also handle the cleanup (i.e. the cleanup section for the binary, just for extensions).

from php.

Hipska avatar Hipska commented on May 18, 2024 1

Thanks, I already figured it out by using zlib1g-dev are the the same?

from php.

JanGalek avatar JanGalek commented on May 18, 2024 1

interbase not work :/

from php.

francislavoie avatar francislavoie commented on May 18, 2024 1

from php.

trashbat avatar trashbat commented on May 18, 2024 1

@mlocati Thanks very much for this script, it just saved my weekend! I needed to install 30+ extensions and it was getting incredibly tedious figuring out the dependencies and "gotchas" for each one. Your script worked perfectly 👍

from php.

rufinus avatar rufinus commented on May 18, 2024 1

i copy/pasted it from a current project where i also needed php_intl - maybe its a left over.

from php.

jmkgreen avatar jmkgreen commented on May 18, 2024

+1 for @MrTrick comment - finally built with LDAP now.

from php.

yosifkit avatar yosifkit commented on May 18, 2024

Most likely, if this route is feasibly maintainable, it should also automatically remove debian packages it installed that were only required to make the module, but not needed for runtime. Ensuring that dynamically linked libraries are kept. Then it also has to assume to do an apt-get update and rm -rf /var/lib/apt/lists/* in order to not affect the layer size excessively.

from php.

schmunk42 avatar schmunk42 commented on May 18, 2024

@yosifkit The list from @carnage contains very useful information, it should be reference from the README https://github.com/docker-library/docs/tree/master/php or added to it.

Where should the place for it in the docs?

from php.

mmeuser avatar mmeuser commented on May 18, 2024

+1 had the same problem and MrTrick's comment helped, thx

from php.

chrissound avatar chrissound commented on May 18, 2024

Yup got frustrated with this issue as well: #279

from php.

stubbetje avatar stubbetje commented on May 18, 2024

Needed ldap module and @MrTrick's comment saved my day

from php.

Hipska avatar Hipska commented on May 18, 2024

What about the zip extension? I need it for a project, but ext-install says:

configure: error: zip support requires ZLIB. Use --with-zlib-dir=

to specify prefix where ZLIB include and library are located

I could not figure out which debian package is needed for that.

from php.

jmkgreen avatar jmkgreen commented on May 18, 2024

For zip add libzip-dev first.

from php.

SanderSander avatar SanderSander commented on May 18, 2024

@rufinus Improvement is always welcome 👍 😄

from php.

kumarldh avatar kumarldh commented on May 18, 2024

@hp9390 you might want to add snmp package to the "almost complete" list.

from php.

hp9390 avatar hp9390 commented on May 18, 2024

For reference, I suggest Laradock: https://github.com/laradock/laradock

from php.

ehuggett avatar ehuggett commented on May 18, 2024

Not all Debian releases will use the same package name for the same dependency, support would need to be per-release not just per distro,

ref: #485 , the php-gd extension requires libpng12-dev (jessie) or libpng-dev (stretch)

edit: it seems libpng-dev is a virtual package in jessie, which installs libpng12-dev. This is a bad example for package name differences (as we can use libpng-dev in both?)

from php.

carnage avatar carnage commented on May 18, 2024

@tianon Perhaps add your comments into the README for the project. Point 2 is something I didn't know existed and is a much better resource than googling the specific error message thrown when something fails to compile.

Happy to put in a PR later next week for it if you think it's a good idea but don't have the time.

from php.

tianon avatar tianon commented on May 18, 2024

@carnage that's a great idea, thanks ❤️

I decided to go with a slightly longer-form explanation in https://tianon.xyz/post/2017/12/26/dockerize-compiled-software.html, which I've sent a PR to link to over in docker-library/docs#1104. 👍

from php.

GusAntoniassi avatar GusAntoniassi commented on May 18, 2024

Some extensions that weren't in the list and I had to install:

  • interbase: apt-install firebird-dev libib-util
  • enchant: apt-install libenchant-dev
  • gmp: apt-install libgmp-dev and also run ln -s /usr/include/x86_64-linux-gnu/gmp.h /usr/include/gmp.h

Note: this was done and tested in Debian, with the php:5.4.45-apache image.

from php.

kelein avatar kelein commented on May 18, 2024

Excuse me. I install ldap extension based php:5.6-fpm-alpine via docker-php-ext-install ldap, but error occurs:

configure: error: Cannot find ldap.h

ERROR: Service 'php' failed to build: The command '/bin/sh -c apk --update add php5-pdo
 php5-mysqli php5-pdo_mysql php5-ldap && docker-php-ext-configure ldap 
 --with-libdir=lib/x86_64-linux-gnu/ && docker-php-ext-install mysqli ldap && 
 rm -rf /var/cache/apk/*' returned a non-zero code: 1

from php.

mlocati avatar mlocati commented on May 18, 2024

for ldap i use this (with 7.2)

RUN  apk add --no-cache --virtual .build-deps $PHPIZE_DEPS icu-dev openldap-dev && \
    docker-php-ext-install ldap  && \
    docker-php-ext-enable ldap && \
    apk del .build-deps

@rufinus are you sure that the above script is correct?
I recently added Alpine support to my install-php-extensions script (so that you can install for example the ldap PHP extension by simply running install-php-extensions ldap), and that script doesn't install the icu-dev package... Is it required? Furthermore, by calling apk del .build-deps, APK will also uninstall the libldap package which is required by the ldap extension to work (without that package, PHP says PHP Warning: PHP Startup: Unable to load dynamic library 'ldap.so').

from php.

rufinus avatar rufinus commented on May 18, 2024

@mlocati - you are right this will not work:

it should be:

RUN set -xe \
 && apk add --no-cache --virtual .build-deps $PHPIZE_DEPS \
 && apk add --no-cache icu-dev openldap-dev \
 && docker-php-ext-install ldap  \
 && docker-php-ext-enable ldap \
 && apk del .build-deps \
 && rm -rf /tmp/* /var/cache/apk/*

from php.

mlocati avatar mlocati commented on May 18, 2024

Why is icu-dev required? Everything seems to be ok even without installing it...

from php.

ustccq avatar ustccq commented on May 18, 2024

@mlocati - you are right this will not work:

it should be:

RUN set -xe \
 && apk add --no-cache --virtual .build-deps $PHPIZE_DEPS \
 && apk add --no-cache icu-dev openldap-dev \
 && docker-php-ext-install ldap  \
 && docker-php-ext-enable ldap \
 && apk del .build-deps \
 && rm -rf /tmp/* /var/cache/apk/*

Works for me, while from daocloud.io/php:7.2-fpm-alpine, there's no apt-get !

from php.

gektor0856 avatar gektor0856 commented on May 18, 2024

@ustccq as stated above, you can use my install-php-extensions script to easily install the ldap PHP extension (as well as many other extensions), both on Alpine and Debian based Docker images.

great! thanks! it works on aarch64

from php.

Related Issues (20)

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.