mirror of
https://github.com/danog/php.git
synced 2024-12-03 09:57:57 +01:00
bb2c469018
Before: ```sh unset HOME if [ "${APACHE_CONFDIR##/etc/apache2-}" != "${APACHE_CONFDIR}" ] ; then SUFFIX="-${APACHE_CONFDIR##/etc/apache2-}" else SUFFIX= fi export APACHE_RUN_USER=www-data export APACHE_RUN_GROUP=www-data export APACHE_PID_FILE=/var/run/apache2/apache2$SUFFIX.pid export APACHE_RUN_DIR=/var/run/apache2$SUFFIX export APACHE_LOCK_DIR=/var/lock/apache2$SUFFIX export APACHE_LOG_DIR=/var/log/apache2$SUFFIX export LANG=C export LANG ``` After: ```sh unset HOME if [ "${APACHE_CONFDIR##/etc/apache2-}" != "${APACHE_CONFDIR}" ] ; then SUFFIX="-${APACHE_CONFDIR##/etc/apache2-}" else SUFFIX= fi : ${APACHE_RUN_USER:=www-data} export APACHE_RUN_USER : ${APACHE_RUN_GROUP:=www-data} export APACHE_RUN_GROUP : ${APACHE_PID_FILE:=/var/run/apache2/apache2$SUFFIX.pid} export APACHE_PID_FILE : ${APACHE_RUN_DIR:=/var/run/apache2$SUFFIX} export APACHE_RUN_DIR : ${APACHE_LOCK_DIR:=/var/lock/apache2$SUFFIX} export APACHE_LOCK_DIR : ${APACHE_LOG_DIR:=/var/log/apache2$SUFFIX} export APACHE_LOG_DIR : ${LANG:=C} export LANG export LANG ``` (minus comments)
57 lines
1.7 KiB
Plaintext
57 lines
1.7 KiB
Plaintext
RUN apt-get update && apt-get install -y apache2-bin apache2.2-common --no-install-recommends && rm -rf /var/lib/apt/lists/*
|
|
|
|
ENV APACHE_CONFDIR /etc/apache2
|
|
ENV APACHE_ENVVARS $APACHE_CONFDIR/envvars
|
|
|
|
RUN set -ex \
|
|
\
|
|
# generically convert lines like
|
|
# export APACHE_RUN_USER=www-data
|
|
# into
|
|
# : ${APACHE_RUN_USER:=www-data}
|
|
# export APACHE_RUN_USER
|
|
# so that they can be overridden at runtime ("-e APACHE_RUN_USER=...")
|
|
&& sed -r 's/^export ([^=]+)=(.*)$/: ${\1:=\2}\nexport \1/' "$APACHE_ENVVARS" \
|
|
\
|
|
# setup directories and permissions
|
|
&& . "$APACHE_ENVVARS" \
|
|
&& for dir in \
|
|
"$APACHE_LOCK_DIR" \
|
|
"$APACHE_RUN_DIR" \
|
|
"$APACHE_LOG_DIR" \
|
|
/var/www/html \
|
|
; do \
|
|
rm -rvf "$dir" \
|
|
&& mkdir -p "$dir" \
|
|
&& chown -R "$APACHE_RUN_USER:$APACHE_RUN_GROUP" "$dir"; \
|
|
done
|
|
|
|
# Apache + PHP requires preforking Apache for best results
|
|
RUN a2dismod mpm_event && a2enmod mpm_prefork
|
|
|
|
# logs should go to stdout / stderr
|
|
RUN set -ex \
|
|
&& . "$APACHE_ENVVARS" \
|
|
&& ln -sfT /dev/stderr "$APACHE_LOG_DIR/error.log" \
|
|
&& ln -sfT /dev/stdout "$APACHE_LOG_DIR/access.log" \
|
|
&& ln -sfT /dev/stdout "$APACHE_LOG_DIR/other_vhosts_access.log"
|
|
|
|
# PHP files should be handled by PHP, and should be preferred over any other file type
|
|
RUN { \
|
|
echo '<FilesMatch \.php$>'; \
|
|
echo '\tSetHandler application/x-httpd-php'; \
|
|
echo '</FilesMatch>'; \
|
|
echo; \
|
|
echo 'DirectoryIndex disabled'; \
|
|
echo 'DirectoryIndex index.php index.html'; \
|
|
echo; \
|
|
echo '<Directory /var/www/>'; \
|
|
echo '\tOptions -Indexes'; \
|
|
echo '\tAllowOverride All'; \
|
|
echo '</Directory>'; \
|
|
} | tee "$APACHE_CONFDIR/conf-available/docker-php.conf" \
|
|
&& a2enconf docker-php
|
|
|
|
ENV PHP_EXTRA_BUILD_DEPS apache2-dev
|
|
ENV PHP_EXTRA_CONFIGURE_ARGS --with-apxs2
|