Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What do docker-php-ext-configure, docker-php-ext-install and docker-php-ext-enable do?

Tags:

php

docker

I'm trying to set up a LAMP web server using docker and was delighted to discover that the good folks over at php have put together a docker container for php.

Reading through the documentation I found three functions that will ostensibly assist me with the installation of php extensions;

  • docker-php-ext-configure
  • docker-php-ext-install
  • docker-php-ext-enable

Being a complete newcomer to php and having tried and failed to enable php modules using a combination of apk add and php.ini hackery (resulting in .so not found errors), I'm ready to admit defeat and do it the proper way.

Unfortunately, the documentation is remarkable vague about what these commands do and how to use them:

We provide the helper scripts docker-php-ext-configure, docker-php-ext-install, and docker-php-ext-enable to more easily install PHP extensions.

I tried to google it as well, but couldn't find any useful resources online either.

I'm now completely confused between what it means to install, configure and install a php extension, and how commands like apk add php7-* relate to all of this.

Please explain what these functions do, and how you would use them to enable php extensions.

like image 999
quant Avatar asked Dec 26 '18 13:12

quant


People also ask

What does Docker PHP ext enable do?

docker-php-ext-enable This command is used to start PHP extension of When we use pecl to install the PHP extension, the extension is not started by default. If you want to use this extension, you must configure it in the php.

Does Docker install PHP?

You don't need to make any changes to the PHP or NGINX configuration on the new server. You don't even need to install PHP or NGINX on the server itself. They'll be automatically installed by Docker when you launch the application. You can run the exact same image on your development machine.


Video Answer


2 Answers

These are helper scripts that helps one install php extensions from source

  • not all extensions are available in a distribution native package manager or pecl
  • even if these exist one may want to configure these differently or optimize

Talking about the scripts

  • docker-php-ext-configure - configure an extension before you build it with docker-php-ext-install. It's executed by docker-php-ext-install, so one should use it if wants to override the defaults
  • docker-php-ext-install - build extension from source, usually executes docker-php-ext-configure for build configuration, enables the extension (php.ini entry) by executing docker-php-ext-enable after all
  • docker-php-ext-enable - enables an already extension by adding a specific entry to php.ini. Extensions installed with pecl or native package managers may not be enabled by default thus require this additional step. As mentioned above, extensions installed with docker-php-ext-install are being enabled automatically.
like image 97
bazeusz Avatar answered Oct 05 '22 23:10

bazeusz


these functions can help to set-up your PHP configuration, if per example you want to add opcache to your PHP configuation:

firstly you configure as below :

docker-php-ext-configure gd \
    --enable-gd-native-ttf \
    --with-jpeg-dir=/usr/lib \
    --with-freetype-dir=/usr/include/freetype2 && \
    docker-php-ext-install gd \

and you install your configuration

  && docker-php-ext-install opcache 

and then you can enable it

  && docker-php-ext-enable opcache
like image 41
Samir Guiderk Avatar answered Oct 05 '22 22:10

Samir Guiderk