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.
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.
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.
These are helper scripts that helps one install php extensions from source
Talking about the scripts
docker-php-ext-install
. It's executed by docker-php-ext-install
, so one should use it if wants to override the defaultsdocker-php-ext-configure
for build configuration, enables the extension (php.ini entry) by executing docker-php-ext-enable
after alldocker-php-ext-install
are being enabled automatically.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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With