├── .gitignore ├── 7.0 ├── apache-xdebug │ ├── Dockerfile │ └── xdebug.ini ├── varnish-xdebug │ ├── xdebug.ini │ └── Dockerfile ├── varnish │ └── Dockerfile ├── apache │ ├── apache2-foreground │ └── Dockerfile ├── onbuild │ └── Dockerfile └── cli │ └── Dockerfile ├── 7.1 ├── apache-xdebug │ ├── Dockerfile │ └── xdebug.ini ├── varnish-xdebug │ ├── xdebug.ini │ └── Dockerfile ├── varnish │ └── Dockerfile ├── apache │ ├── apache2-foreground │ └── Dockerfile ├── onbuild │ └── Dockerfile └── cli │ └── Dockerfile └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /7.0/apache-xdebug/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM louisbl/php:7.0-apache 2 | MAINTAINER louisbl 3 | 4 | COPY xdebug.ini /usr/local/etc/php/conf.d/xdebug.ini 5 | RUN pecl install xdebug && docker-php-ext-enable xdebug 6 | -------------------------------------------------------------------------------- /7.0/apache-xdebug/xdebug.ini: -------------------------------------------------------------------------------- 1 | [Xdebug] 2 | xdebug.remote_enable=on 3 | xdebug.remote_port=9000 4 | xdebug.remote_connect_back=Off 5 | xdebug.remote_handler=dbgp 6 | xdebug.profiler_enable=0 7 | xdebug.remote_host=172.17.0.1 8 | -------------------------------------------------------------------------------- /7.0/varnish-xdebug/xdebug.ini: -------------------------------------------------------------------------------- 1 | [Xdebug] 2 | xdebug.remote_enable=on 3 | xdebug.remote_port=9000 4 | xdebug.remote_connect_back=Off 5 | xdebug.remote_handler=dbgp 6 | xdebug.profiler_enable=0 7 | xdebug.remote_host=172.17.0.1 8 | -------------------------------------------------------------------------------- /7.1/apache-xdebug/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM louisbl/php:7.1-apache 2 | MAINTAINER louisbl 3 | 4 | COPY xdebug.ini /usr/local/etc/php/conf.d/xdebug.ini 5 | RUN pecl install xdebug && docker-php-ext-enable xdebug 6 | -------------------------------------------------------------------------------- /7.1/apache-xdebug/xdebug.ini: -------------------------------------------------------------------------------- 1 | [Xdebug] 2 | xdebug.remote_enable=on 3 | xdebug.remote_port=9000 4 | xdebug.remote_connect_back=Off 5 | xdebug.remote_handler=dbgp 6 | xdebug.profiler_enable=0 7 | xdebug.remote_host=172.17.0.1 8 | -------------------------------------------------------------------------------- /7.1/varnish-xdebug/xdebug.ini: -------------------------------------------------------------------------------- 1 | [Xdebug] 2 | xdebug.remote_enable=on 3 | xdebug.remote_port=9000 4 | xdebug.remote_connect_back=Off 5 | xdebug.remote_handler=dbgp 6 | xdebug.profiler_enable=0 7 | xdebug.remote_host=172.17.0.1 8 | -------------------------------------------------------------------------------- /7.0/varnish-xdebug/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM louisbl/php:7.0-varnish 2 | MAINTAINER louisbl 3 | 4 | COPY xdebug.ini /usr/local/etc/php/conf.d/xdebug.ini 5 | RUN pecl install xdebug && docker-php-ext-enable xdebug 6 | -------------------------------------------------------------------------------- /7.1/varnish-xdebug/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM louisbl/php:7.1-varnish 2 | MAINTAINER louisbl 3 | 4 | COPY xdebug.ini /usr/local/etc/php/conf.d/xdebug.ini 5 | RUN pecl install xdebug && docker-php-ext-enable xdebug 6 | -------------------------------------------------------------------------------- /7.0/varnish/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM louisbl/php:7.0-apache 2 | MAINTAINER louisbl 3 | 4 | RUN apt-get update && apt-get install -y apt-transport-https 5 | RUN curl https://repo.varnish-cache.org/debian/GPG-key.txt | apt-key add - 6 | RUN echo "deb https://repo.varnish-cache.org/debian/ jessie varnish-4.1" >> /etc/apt/sources.list.d/varnish-cache.list \ 7 | && apt-get update \ 8 | && apt-get install -y varnish 9 | 10 | EXPOSE 6081 11 | -------------------------------------------------------------------------------- /7.1/varnish/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM louisbl/php:7.1-apache 2 | MAINTAINER louisbl 3 | 4 | RUN apt-get update && apt-get install -y apt-transport-https 5 | RUN curl https://repo.varnish-cache.org/debian/GPG-key.txt | apt-key add - 6 | RUN echo "deb https://repo.varnish-cache.org/debian/ jessie varnish-4.1" >> /etc/apt/sources.list.d/varnish-cache.list \ 7 | && apt-get update \ 8 | && apt-get install -y varnish 9 | 10 | EXPOSE 6081 11 | -------------------------------------------------------------------------------- /7.0/apache/apache2-foreground: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | # Note: we don't just use "apache2ctl" here because it itself is just a shell-script wrapper around apache2 which provides extra functionality like "apache2ctl start" for launching apache2 in the background. 5 | # (also, when run as "apache2ctl ", it does not use "exec", which leaves an undesirable resident shell process) 6 | 7 | : "${APACHE_CONFDIR:=/etc/apache2}" 8 | : "${APACHE_ENVVARS:=$APACHE_CONFDIR/envvars}" 9 | if test -f "$APACHE_ENVVARS"; then 10 | . "$APACHE_ENVVARS" 11 | fi 12 | 13 | # Apache gets grumpy about PID files pre-existing 14 | : "${APACHE_PID_FILE:=${APACHE_RUN_DIR:=/var/run/apache2}/apache2.pid}" 15 | rm -f "$APACHE_PID_FILE" 16 | 17 | exec service varnish start & 18 | exec php-fpm & 19 | exec apache2 -DFOREGROUND "$@" 20 | -------------------------------------------------------------------------------- /7.1/apache/apache2-foreground: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | # Note: we don't just use "apache2ctl" here because it itself is just a shell-script wrapper around apache2 which provides extra functionality like "apache2ctl start" for launching apache2 in the background. 5 | # (also, when run as "apache2ctl ", it does not use "exec", which leaves an undesirable resident shell process) 6 | 7 | : "${APACHE_CONFDIR:=/etc/apache2}" 8 | : "${APACHE_ENVVARS:=$APACHE_CONFDIR/envvars}" 9 | if test -f "$APACHE_ENVVARS"; then 10 | . "$APACHE_ENVVARS" 11 | fi 12 | 13 | # Apache gets grumpy about PID files pre-existing 14 | : "${APACHE_PID_FILE:=${APACHE_RUN_DIR:=/var/run/apache2}/apache2.pid}" 15 | rm -f "$APACHE_PID_FILE" 16 | 17 | exec service varnish start & 18 | exec php-fpm & 19 | exec apache2 -DFOREGROUND "$@" 20 | -------------------------------------------------------------------------------- /7.0/onbuild/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM louisbl/php:7.0-apache 2 | MAINTAINER louisbl 3 | 4 | # Install Nodejs, Git, ssh & mysql clients 5 | RUN cd /tmp && curl -sL https://deb.nodesource.com/setup_6.x | bash - 6 | RUN apt-get update && apt-get install -y \ 7 | git \ 8 | openssh-client \ 9 | mysql-client \ 10 | nodejs \ 11 | && rm -rf /var/lib/apt/lists/* 12 | RUN npm install yarn -g 13 | 14 | # Install Composer 15 | RUN curl -sS https://getcomposer.org/installer \ 16 | | php -- --install-dir=/usr/local/bin --filename=composer \ 17 | && mkdir -p /var/www/composer-cache \ 18 | && chmod 777 /var/www/composer-cache \ 19 | && composer config -g cache-dir /var/www/composer-cache 20 | 21 | WORKDIR /var/www 22 | 23 | # npm deps 24 | ONBUILD COPY package.json /var/www/ 25 | ONBUILD RUN yarn 26 | 27 | # Composer deps 28 | ONBUILD COPY auth.json /var/www/ 29 | ONBUILD COPY composer.json /var/www/ 30 | ONBUILD COPY composer.lock /var/www/ 31 | ONBUILD RUN composer install --prefer-dist --no-progress --no-dev -o 32 | 33 | # custom code 34 | ONBUILD COPY . /var/www/ 35 | -------------------------------------------------------------------------------- /7.1/onbuild/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM louisbl/php:7.1-apache 2 | MAINTAINER louisbl 3 | 4 | # Install Nodejs, Git, ssh & mysql clients 5 | RUN cd /tmp && curl -sL https://deb.nodesource.com/setup_6.x | bash - 6 | RUN apt-get update && apt-get install -y \ 7 | git \ 8 | openssh-client \ 9 | mysql-client \ 10 | nodejs \ 11 | && rm -rf /var/lib/apt/lists/* 12 | RUN npm install yarn -g 13 | 14 | # Install Composer 15 | RUN curl -sS https://getcomposer.org/installer \ 16 | | php -- --install-dir=/usr/local/bin --filename=composer \ 17 | && mkdir -p /var/www/composer-cache \ 18 | && chmod 777 /var/www/composer-cache \ 19 | && composer config -g cache-dir /var/www/composer-cache 20 | 21 | WORKDIR /var/www 22 | 23 | # npm deps 24 | ONBUILD COPY package.json /var/www/ 25 | ONBUILD RUN yarn 26 | 27 | # Composer deps 28 | ONBUILD COPY auth.json /var/www/ 29 | ONBUILD COPY composer.json /var/www/ 30 | ONBUILD COPY composer.lock /var/www/ 31 | ONBUILD RUN composer install --prefer-dist --no-progress --no-dev -o 32 | 33 | # custom code 34 | ONBUILD COPY . /var/www/ 35 | -------------------------------------------------------------------------------- /7.0/cli/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM php:7.3-cli 2 | MAINTAINER louisbl 3 | 4 | RUN apt-get update && apt-get install -y \ 5 | g++ \ 6 | git \ 7 | imagemagick \ 8 | libbz2-dev \ 9 | libfreetype6-dev \ 10 | libicu-dev \ 11 | libjpeg62-turbo-dev \ 12 | libmcrypt-dev \ 13 | libpng12-dev \ 14 | libpq-dev \ 15 | libxslt1-dev \ 16 | libzip-dev \ 17 | mysql-client \ 18 | openssh-client \ 19 | zlib1g-dev \ 20 | && rm -rf /var/lib/apt/lists/* 21 | 22 | RUN mkdir /usr/include/freetype2/freetype && ln -s /usr/include/freetype2/freetype.h /usr/include/freetype2/freetype/freetype.h 23 | 24 | RUN docker-php-ext-configure gd --with-jpeg-dir --with-freetype-dir --enable-gd-native-ttf \ 25 | && docker-php-ext-install -j$(nproc) \ 26 | bz2 \ 27 | gd \ 28 | exif \ 29 | intl \ 30 | mbstring \ 31 | mcrypt \ 32 | mysqli \ 33 | pdo_mysql \ 34 | zip 35 | 36 | RUN echo "date.timezone = \"Europe/Paris\"" > /usr/local/etc/php/conf.d/timezone.ini 37 | RUN echo "memory_limit=-1" > /usr/local/etc/php/conf.d/memory-limit.ini 38 | RUN echo "zend.enable_gc=0" > /usr/local/etc/php/conf.d/disable-gc.ini 39 | 40 | RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer 41 | -------------------------------------------------------------------------------- /7.1/cli/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM php:7.1-cli 2 | MAINTAINER louisbl 3 | 4 | RUN apt-get update && apt-get install -y \ 5 | g++ \ 6 | git \ 7 | imagemagick \ 8 | libbz2-dev \ 9 | libfreetype6-dev \ 10 | libicu-dev \ 11 | libjpeg62-turbo-dev \ 12 | libmcrypt-dev \ 13 | libpng12-dev \ 14 | libpq-dev \ 15 | libxslt1-dev \ 16 | libzip-dev \ 17 | mysql-client \ 18 | openssh-client \ 19 | zlib1g-dev \ 20 | && rm -rf /var/lib/apt/lists/* 21 | 22 | RUN mkdir /usr/include/freetype2/freetype && ln -s /usr/include/freetype2/freetype.h /usr/include/freetype2/freetype/freetype.h 23 | 24 | RUN docker-php-ext-configure gd --with-jpeg-dir --with-freetype-dir --enable-gd-native-ttf \ 25 | && docker-php-ext-install -j$(nproc) \ 26 | bz2 \ 27 | gd \ 28 | exif \ 29 | intl \ 30 | mbstring \ 31 | mcrypt \ 32 | mysqli \ 33 | pdo_mysql \ 34 | zip 35 | 36 | RUN echo "date.timezone = \"Europe/Paris\"" > /usr/local/etc/php/conf.d/timezone.ini 37 | RUN echo "memory_limit=-1" > /usr/local/etc/php/conf.d/memory-limit.ini 38 | RUN echo "zend.enable_gc=0" > /usr/local/etc/php/conf.d/disable-gc.ini 39 | 40 | RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer 41 | -------------------------------------------------------------------------------- /7.0/apache/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM php:7.0-fpm 2 | MAINTAINER louisbl 3 | 4 | RUN apt-get update && apt-get install -y \ 5 | g++ \ 6 | imagemagick \ 7 | libbz2-dev \ 8 | libfreetype6-dev \ 9 | libicu-dev \ 10 | libjpeg62-turbo-dev \ 11 | libmcrypt-dev \ 12 | libpng12-dev \ 13 | libpq-dev \ 14 | libxml2-dev \ 15 | libzip-dev \ 16 | zlib1g-dev \ 17 | mysql-client \ 18 | && rm -rf /var/lib/apt/lists/* 19 | 20 | RUN mkdir /usr/include/freetype2/freetype && ln -s /usr/include/freetype2/freetype.h /usr/include/freetype2/freetype/freetype.h 21 | 22 | RUN pecl install apcu \ 23 | && docker-php-ext-enable apcu 24 | 25 | RUN docker-php-ext-configure gd --with-jpeg-dir --with-freetype-dir --enable-gd-native-ttf \ 26 | && docker-php-ext-configure pdo_mysql --with-pdo-mysql=mysqlnd \ 27 | && docker-php-ext-install -j$(nproc) \ 28 | bz2 \ 29 | gd \ 30 | exif \ 31 | intl \ 32 | json \ 33 | mbstring \ 34 | mcrypt \ 35 | xmlrpc \ 36 | bcmath \ 37 | opcache \ 38 | pdo_mysql \ 39 | mysqli \ 40 | zip 41 | 42 | # set recommended PHP.ini settings 43 | # see https://secure.php.net/manual/en/opcache.installation.php 44 | RUN { \ 45 | echo 'opcache.memory_consumption=128'; \ 46 | echo 'opcache.interned_strings_buffer=8'; \ 47 | echo 'opcache.max_accelerated_files=4000'; \ 48 | echo 'opcache.revalidate_freq=60'; \ 49 | echo 'opcache.fast_shutdown=1'; \ 50 | echo 'opcache.enable_cli=0'; \ 51 | } > /usr/local/etc/php/conf.d/opcache-recommended.ini 52 | RUN echo "date.timezone = \"Europe/Paris\"" > /usr/local/etc/php/conf.d/timezone.ini 53 | 54 | RUN apt-get update && apt-get install -y apache2-bin apache2.2-common --no-install-recommends && rm -rf /var/lib/apt/lists/* 55 | 56 | ENV APACHE_CONFDIR /etc/apache2 57 | ENV APACHE_ENVVARS $APACHE_CONFDIR/envvars 58 | 59 | RUN set -ex \ 60 | \ 61 | # generically convert lines like 62 | # export APACHE_RUN_USER=www-data 63 | # into 64 | # : ${APACHE_RUN_USER:=www-data} 65 | # export APACHE_RUN_USER 66 | # so that they can be overridden at runtime ("-e APACHE_RUN_USER=...") 67 | && sed -ri 's/^export ([^=]+)=(.*)$/: ${\1:=\2}\nexport \1/' "$APACHE_ENVVARS" \ 68 | \ 69 | # setup directories and permissions 70 | && . "$APACHE_ENVVARS" \ 71 | && for dir in \ 72 | "$APACHE_LOCK_DIR" \ 73 | "$APACHE_RUN_DIR" \ 74 | "$APACHE_LOG_DIR" \ 75 | /var/www/html \ 76 | ; do \ 77 | rm -rvf "$dir" \ 78 | && mkdir -p "$dir" \ 79 | && chown -R "$APACHE_RUN_USER:$APACHE_RUN_GROUP" "$dir"; \ 80 | done 81 | 82 | # logs should go to stdout / stderr 83 | RUN set -ex \ 84 | && . "$APACHE_ENVVARS" \ 85 | && ln -sfT /dev/stderr "$APACHE_LOG_DIR/error.log" \ 86 | && ln -sfT /dev/stdout "$APACHE_LOG_DIR/access.log" \ 87 | && ln -sfT /dev/stdout "$APACHE_LOG_DIR/other_vhosts_access.log" 88 | 89 | # PHP files should be handled by PHP, and should be preferred over any other file type 90 | RUN { \ 91 | echo ''; \ 92 | echo '\tSetHandler "proxy:fcgi://127.0.0.1:9000"'; \ 93 | echo ''; \ 94 | echo; \ 95 | echo 'DirectoryIndex disabled'; \ 96 | echo 'DirectoryIndex index.php index.html'; \ 97 | echo; \ 98 | echo ''; \ 99 | echo '\tOptions -Indexes'; \ 100 | echo '\tAllowOverride All'; \ 101 | echo ''; \ 102 | } | tee "$APACHE_CONFDIR/conf-available/docker-php.conf" \ 103 | && a2enconf docker-php 104 | 105 | RUN a2enmod proxy_fcgi 106 | 107 | COPY apache2-foreground /usr/local/bin/ 108 | WORKDIR /var/www/html 109 | EXPOSE 80 110 | CMD ["apache2-foreground"] 111 | -------------------------------------------------------------------------------- /7.1/apache/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM php:7.3.33-fpm-buster 2 | MAINTAINER louisbl 3 | 4 | RUN apt-get update && apt-get install -y \ 5 | g++ \ 6 | imagemagick \ 7 | libbz2-dev \ 8 | libfreetype6-dev \ 9 | libicu-dev \ 10 | libjpeg62-turbo-dev \ 11 | libmcrypt-dev \ 12 | libpng12-dev \ 13 | libpq-dev \ 14 | libxml2-dev \ 15 | libzip-dev \ 16 | zlib1g-dev \ 17 | mysql-client \ 18 | && rm -rf /var/lib/apt/lists/* 19 | 20 | RUN mkdir /usr/include/freetype2/freetype && ln -s /usr/include/freetype2/freetype.h /usr/include/freetype2/freetype/freetype.h 21 | 22 | RUN pecl install apcu \ 23 | && docker-php-ext-enable apcu 24 | 25 | RUN docker-php-ext-configure gd --with-jpeg-dir --with-freetype-dir --enable-gd-native-ttf \ 26 | && docker-php-ext-configure pdo_mysql --with-pdo-mysql=mysqlnd \ 27 | && docker-php-ext-install -j$(nproc) \ 28 | bz2 \ 29 | gd \ 30 | exif \ 31 | intl \ 32 | json \ 33 | mbstring \ 34 | mcrypt \ 35 | xmlrpc \ 36 | bcmath \ 37 | opcache \ 38 | pdo_mysql \ 39 | mysqli \ 40 | zip 41 | 42 | # set recommended PHP.ini settings 43 | # see https://secure.php.net/manual/en/opcache.installation.php 44 | RUN { \ 45 | echo 'opcache.memory_consumption=128'; \ 46 | echo 'opcache.interned_strings_buffer=8'; \ 47 | echo 'opcache.max_accelerated_files=4000'; \ 48 | echo 'opcache.revalidate_freq=60'; \ 49 | echo 'opcache.fast_shutdown=1'; \ 50 | echo 'opcache.enable_cli=0'; \ 51 | } > /usr/local/etc/php/conf.d/opcache-recommended.ini 52 | RUN echo "date.timezone = \"Europe/Paris\"" > /usr/local/etc/php/conf.d/timezone.ini 53 | 54 | RUN apt-get update && apt-get install -y apache2-bin apache2.2-common --no-install-recommends && rm -rf /var/lib/apt/lists/* 55 | 56 | ENV APACHE_CONFDIR /etc/apache2 57 | ENV APACHE_ENVVARS $APACHE_CONFDIR/envvars 58 | 59 | RUN set -ex \ 60 | \ 61 | # generically convert lines like 62 | # export APACHE_RUN_USER=www-data 63 | # into 64 | # : ${APACHE_RUN_USER:=www-data} 65 | # export APACHE_RUN_USER 66 | # so that they can be overridden at runtime ("-e APACHE_RUN_USER=...") 67 | && sed -ri 's/^export ([^=]+)=(.*)$/: ${\1:=\2}\nexport \1/' "$APACHE_ENVVARS" \ 68 | \ 69 | # setup directories and permissions 70 | && . "$APACHE_ENVVARS" \ 71 | && for dir in \ 72 | "$APACHE_LOCK_DIR" \ 73 | "$APACHE_RUN_DIR" \ 74 | "$APACHE_LOG_DIR" \ 75 | /var/www/html \ 76 | ; do \ 77 | rm -rvf "$dir" \ 78 | && mkdir -p "$dir" \ 79 | && chown -R "$APACHE_RUN_USER:$APACHE_RUN_GROUP" "$dir"; \ 80 | done 81 | 82 | # logs should go to stdout / stderr 83 | RUN set -ex \ 84 | && . "$APACHE_ENVVARS" \ 85 | && ln -sfT /dev/stderr "$APACHE_LOG_DIR/error.log" \ 86 | && ln -sfT /dev/stdout "$APACHE_LOG_DIR/access.log" \ 87 | && ln -sfT /dev/stdout "$APACHE_LOG_DIR/other_vhosts_access.log" 88 | 89 | # PHP files should be handled by PHP, and should be preferred over any other file type 90 | RUN { \ 91 | echo ''; \ 92 | echo '\tSetHandler "proxy:fcgi://127.0.0.1:9000"'; \ 93 | echo ''; \ 94 | echo; \ 95 | echo 'DirectoryIndex disabled'; \ 96 | echo 'DirectoryIndex index.php index.html'; \ 97 | echo; \ 98 | echo ''; \ 99 | echo '\tOptions -Indexes'; \ 100 | echo '\tAllowOverride All'; \ 101 | echo ''; \ 102 | } | tee "$APACHE_CONFDIR/conf-available/docker-php.conf" \ 103 | && a2enconf docker-php 104 | 105 | RUN a2enmod proxy_fcgi 106 | 107 | COPY apache2-foreground /usr/local/bin/ 108 | WORKDIR /var/www/html 109 | EXPOSE 80 110 | CMD ["apache2-foreground"] 111 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Supported tags and respective `Dockerfile` links 2 | 3 | - [`7.0-apache` (*7.0/apache/Dockerfile*)](https://github.com/louisbl/docker-php/blob/master/7.0/apache/Dockerfile) 4 | - [`7.0-apache-xdebug` (*7.0/apache-xdebug/Dockerfile*)](https://github.com/louisbl/docker-php/blob/master/7.0/apache-xdebug/Dockerfile) 5 | - [`7.0-cli` (*7.0/cli/Dockerfile*)](https://github.com/louisbl/docker-php/blob/master/7.0/cli/Dockerfile) 6 | - [`7.0-onbuild` (*7.0/onbuild/Dockerfile*)](https://github.com/louisbl/docker-php/blob/master/7.0/onbuild/Dockerfile) 7 | - [`7.0-varnish` (*7.0/varnish/Dockerfile*)](https://github.com/louisbl/docker-php/blob/master/7.0/varnish/Dockerfile) 8 | - [`7.0-varnish-xdebug` (*7.0/varnish-xdebug/Dockerfile*)](https://github.com/louisbl/docker-php/blob/master/7.0/varnish-xdebug/Dockerfile) 9 | - [`7.1-apache` (*7.1/apache/Dockerfile*)](https://github.com/louisbl/docker-php/blob/master/7.1/apache/Dockerfile) 10 | - [`7.1-apache-xdebug` (*7.1/apache-xdebug/Dockerfile*)](https://github.com/louisbl/docker-php/blob/master/7.1/apache-xdebug/Dockerfile) 11 | - [`7.1-cli` (*7.1/cli/Dockerfile*)](https://github.com/louisbl/docker-php/blob/master/7.1/cli/Dockerfile) 12 | - [`7.1-onbuild` (*7.1/onbuild/Dockerfile*)](https://github.com/louisbl/docker-php/blob/master/7.1/onbuild/Dockerfile) 13 | - [`7.1-varnish` (*7.1/varnish/Dockerfile*)](https://github.com/louisbl/docker-php/blob/master/7.1/varnish/Dockerfile) 14 | - [`7.1-varnish-xdebug` (*7.1/varnish-xdebug/Dockerfile*)](https://github.com/louisbl/docker-php/blob/master/7.1/varnish-xdebug/Dockerfile) 15 | 16 | For more information about this image and its history, please see the [relevant manifest file (`library/php`)](https://github.com/docker-library/official-images/blob/master/library/php) in the [`docker-library/official-images` GitHub repo](https://github.com/docker-library/official-images). 17 | 18 | ![logo](https://raw.githubusercontent.com/docker-library/docs/master/php/logo.png) 19 | 20 | # How to use this image. 21 | 22 | ## With Command Line 23 | 24 | For PHP projects run through the command line interface (CLI), you can do the following. 25 | 26 | ### Create a `Dockerfile` in your PHP project 27 | 28 | FROM louisbl/php:7.1-cli 29 | COPY . /usr/src/myapp 30 | WORKDIR /usr/src/myapp 31 | CMD [ "php", "./your-script.php" ] 32 | 33 | Then, run the commands to build and run the Docker image: 34 | 35 | docker build -t my-php-app . 36 | docker run -it --rm --name my-running-app my-php-app 37 | 38 | ## With Apache 39 | 40 | More commonly, you will probably want to run PHP in conjunction with Apache httpd. Conveniently, there's a version of the PHP container that's packaged with the Apache web server. 41 | 42 | ### Create a `Dockerfile` in your PHP project 43 | 44 | FROM louisbl/php:7.1-apache 45 | COPY src/ /var/www/html/ 46 | 47 | Where `src/` is the directory containing all your php code. Then, run the commands to build and run the Docker image: 48 | 49 | docker build -t my-php-app . 50 | docker run -it --rm --name my-running-app my-php-app 51 | 52 | We recommend that you add a custom `php.ini` configuration. `COPY` it into `/usr/local/etc/php` by adding one more line to the Dockerfile above and running the same commands to build and run: 53 | 54 | FROM louisbl/php:7.1-apache 55 | COPY config/php.ini /usr/local/etc/php 56 | COPY src/ /var/www/html/ 57 | 58 | Where `src/` is the directory containing all your php code and `config/` contains your `php.ini` file. 59 | 60 | ## Apache modules 61 | 62 | ### Apache modules already loaded 63 | 64 | - mod_rewrite 65 | 66 | ### How to install more Apache modules 67 | 68 | Add this line to your Dockerfile: 69 | `RUN a2enmod rewrite` 70 | 71 | ## PHP extensions 72 | 73 | ### PHP extensions already loaded 74 | 75 | - mysqlnd 76 | - curl 77 | - openssl 78 | - pcre 79 | - readline 80 | - recode 81 | - zlib 82 | - bz2 83 | - gd (jpg/png/ttf) 84 | - intl 85 | - mbstring 86 | - mcrypt 87 | - mysqli 88 | - pdo_mysql 89 | - pdo_pgsql 90 | - pgsql 91 | - zip 92 | 93 | ### How to install more PHP extensions 94 | 95 | We provide two convenient scripts named `docker-php-ext-configure` and `docker-php-ext-install -j$(nproc)`, you can use them to easily install PHP extension. 96 | 97 | For example, if you want to have a PHP-FPM image with `iconv`, `mcrypt` and `gd` extensions, you can inheriting the base image that you like, and write your own `Dockerfile` like this: 98 | 99 | ```docker 100 | FROM louisbl/php:7.1-fpm 101 | # Install modules 102 | RUN apt-get update && apt-get install -y \ 103 | libfreetype6-dev \ 104 | libjpeg62-turbo-dev \ 105 | libmcrypt-dev \ 106 | libpng12-dev \ 107 | && docker-php-ext-install -j$(nproc) iconv mcrypt \ 108 | && docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \ 109 | && docker-php-ext-install -j$(nproc) gd 110 | CMD ["php-fpm"] 111 | ``` 112 | 113 | Remember, you must install dependencies for your extensions manually. If an extension needs custom `configure` arguments, you can use the `docker-php-ext-configure` script like this example. 114 | 115 | # License 116 | 117 | View [license information](http://php.net/license/) for the software contained in this image. 118 | 119 | # Supported Docker versions 120 | 121 | This image is officially supported on Docker version 1.7.0. 122 | 123 | Support for older versions (down to 1.0) is provided on a best-effort basis. 124 | --------------------------------------------------------------------------------