Reputation: 3317
I want to run a apache webserver with php extension inside container using docker compose as deployment.
My compose file looks like this:
version: '3.1'
services:
php:
image: php:7.2-apache
ports:
- 8089:80
volumes:
- ./php/www:/var/www/html/
how can I enable the following extensions.
apache2
php7.2
php-xdebug
php7.2-mcrypt
php-apcu
php-apcu-bc
php7.2-json
php-imagick
php-gettext
php7.2-mbstring
Upvotes: 1
Views: 8643
Reputation: 4123
First of all you can run php -m
in php
container to see installed and enabled modules.
You can edit your docker-compose.yml
like this:
version: '3.1'
services:
php:
# image: php:7.2-apache # remember to comment this line
build: .
ports:
- 8089:80
volumes:
- ./php/www:/var/www/html/
Create a file called Dockerfile
beside docker-compose.yml
with the following contents:
FROM php:7.2-apache
# then add the following `RUN ...` lines in each separate line, like this:
RUN pecl install xdebug && docker-php-ext-enable xdebug
...
Finally, let's go one by one:
Is installed.
Is enabled.
Add Dockerfile
:
RUN pecl install xdebug && docker-php-ext-enable xdebug
Add to Dockerfile
:
RUN apt-get install libmcrypt-dev
RUN pecl install mcrypt && docker-php-ext-enable mcrypt
Add to Dockerfile
:
RUN pecl install apcu && docker-php-ext-enable apcu
Add to Dockerfile
:
RUN pecl install apcu_bc
RUN cp /usr/local/etc/php/php.ini-production /usr/local/etc/php/php.ini
RUN echo 'extension=apc.so' >> /usr/local/etc/php/php.ini
Is installed.
Add to Dockerfile
:
RUN apt install -y libmagickwand-dev --no-install-recommends && \
pecl install imagick && docker-php-ext-enable imagick
Add to Dockerfile
:
RUN docker-php-ext-install gettext && \
docker-php-ext-enable gettext
Is enabled.
Upvotes: 10