Skip to content

Instantly share code, notes, and snippets.

@heckad
Last active October 6, 2022 16:04
Show Gist options
  • Save heckad/29f54df75777f977e49c075e7a267fb5 to your computer and use it in GitHub Desktop.
Save heckad/29f54df75777f977e49c075e7a267fb5 to your computer and use it in GitHub Desktop.
Dockerfile for creating container with php5.4 and xdebug
FROM php:5.4-apache
# This image is not to be used on a production server!
# I use it for local development on old projects (hence the PHP version).
# Install gd, iconv, mbstring, mcrypt, mysql, soap, sockets, and zip extensions
# see example at https://hub.docker.com/_/php/
RUN apt-get update
RUN apt-get install -y \
libbz2-dev \
libfreetype6-dev \
libjpeg62-turbo-dev \
libmcrypt-dev \
libpng12-dev \
libxml2-dev \
libxslt-dev \
&& docker-php-ext-install iconv mbstring mcrypt soap sockets zip \
&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
&& docker-php-ext-install gd \
&& docker-php-ext-configure mysql --with-mysql=mysqlnd \
&& docker-php-ext-install pdo_mysql xsl
# Install xdebug. Couldn't connect to it in my boot2docker instance, useful
# nonetheless.
# IMPORTANT: These settings are not recommended for production servers!
RUN pecl install xdebug-2.3.3
RUN docker-php-ext-enable xdebug
RUN echo ';xdebug.scream=1' >> cxdebug.ini \
&& echo 'xdebug.remote_enable=1' >> /usr/local/etc/php/conf.d/xdebug.ini \
&& echo 'xdebug.remote_autostart=1' >> /usr/local/etc/php/conf.d/xdebug.ini \
&& echo 'xdebug.remote_connect_back=1' >> /usr/local/etc/php/conf.d/xdebug.ini \
&& echo 'xdebug.remote_port=9000' >> /usr/local/etc/php/conf.d/xdebug.ini \
&& echo 'xdebug.remote_mode=req' >> /usr/local/etc/php/conf.d/xdebug.ini \
&& echo 'xdebug.remote_handler=dbgp' >> /usr/local/etc/php/conf.d/xdebug.ini \
&& echo 'xdebug.remote_log=/tmp/php5-xdebug.log' >> /usr/local/etc/php/conf.d/xdebug.ini
## enable mod_rewrite
RUN a2enmod rewrite
# make the webroot a volume
VOLUME /var/www/html/
# support jwilder/nginx-proxy resp. docker-gen
# You may wan to overwrite VIRTUAL_HOST in your Docker file.
EXPOSE 80
ENV VIRTUAL_HOST site.local
ENV UPSTREAM_NAME web-site
# Add a PHP config file. The file was copied from a php53 dotdeb package and
# lightly modified (mostly for improving debugging). This may not be the best
# idea.
COPY config/php.ini /usr/local/etc/php/
#EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment