Skip to content

Instantly share code, notes, and snippets.

@bizm
Created October 31, 2023 12:20
Show Gist options
  • Save bizm/c463142784eee59b5b7fd4701d3bf5f6 to your computer and use it in GitHub Desktop.
Save bizm/c463142784eee59b5b7fd4701d3bf5f6 to your computer and use it in GitHub Desktop.
PHP dockerfile with XDebug
FROM php:7.4-apache
RUN apt-get update && apt-get install -y \
libfreetype6-dev \
libjpeg62-turbo-dev \
libpng-dev \
vim \
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
&& docker-php-ext-install -j$(nproc) gd
RUN apt-get install -y libzip-dev \
&& docker-php-ext-configure zip \
&& docker-php-ext-install zip mysqli
RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" \
&& php composer-setup.php --install-dir=/usr/local/bin --filename=composer \
&& php -r "unlink('composer-setup.php');"
RUN pecl install xdebug-2.8.1 \
&& docker-php-ext-enable xdebug
RUN mv "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini"
RUN echo "zend_extension=xdebug" >> "$PHP_INI_DIR/php.ini"
RUN echo "xdebug.remote_enable = 1" >> "$PHP_INI_DIR/php.ini"
RUN echo "xdebug.remote_autostart = 1" >> "$PHP_INI_DIR/php.ini"
RUN echo "xdebug.remote_port = 9000" >> "$PHP_INI_DIR/php.ini"
WORKDIR /var/www/html
RUN a2enmod rewrite \
&& a2enmod headers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment