2016-07-07 01:07:32 +02:00
|
|
|
ENV APACHE_CONFDIR /etc/apache2
|
|
|
|
ENV APACHE_ENVVARS $APACHE_CONFDIR/envvars
|
|
|
|
|
2018-11-27 01:16:38 +01:00
|
|
|
RUN set -eux; \
|
2019-01-31 23:45:15 +01:00
|
|
|
apt-get update; \
|
|
|
|
apt-get install -y --no-install-recommends apache2; \
|
|
|
|
rm -rf /var/lib/apt/lists/*; \
|
2016-08-02 02:03:07 +02:00
|
|
|
\
|
|
|
|
# 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=...")
|
2018-11-27 01:16:38 +01:00
|
|
|
sed -ri 's/^export ([^=]+)=(.*)$/: ${\1:=\2}\nexport \1/' "$APACHE_ENVVARS"; \
|
2016-08-02 02:03:07 +02:00
|
|
|
\
|
|
|
|
# setup directories and permissions
|
2018-11-27 01:16:38 +01:00
|
|
|
. "$APACHE_ENVVARS"; \
|
|
|
|
for dir in \
|
2016-07-07 01:07:32 +02:00
|
|
|
"$APACHE_LOCK_DIR" \
|
|
|
|
"$APACHE_RUN_DIR" \
|
|
|
|
"$APACHE_LOG_DIR" \
|
|
|
|
; do \
|
2018-11-27 01:16:38 +01:00
|
|
|
rm -rvf "$dir"; \
|
|
|
|
mkdir -p "$dir"; \
|
|
|
|
chown "$APACHE_RUN_USER:$APACHE_RUN_GROUP" "$dir"; \
|
2018-11-13 00:51:08 +01:00
|
|
|
# allow running as an arbitrary user (https://github.com/docker-library/php/issues/743)
|
2018-11-27 01:16:38 +01:00
|
|
|
chmod 777 "$dir"; \
|
|
|
|
done; \
|
|
|
|
\
|
2019-01-31 23:45:15 +01:00
|
|
|
# delete the "index.html" that installing Apache drops in here
|
|
|
|
rm -rvf /var/www/html/*; \
|
|
|
|
\
|
2018-11-27 01:16:38 +01:00
|
|
|
# logs should go to stdout / stderr
|
|
|
|
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"; \
|
|
|
|
chown -R --no-dereference "$APACHE_RUN_USER:$APACHE_RUN_GROUP" "$APACHE_LOG_DIR"
|
2014-11-07 01:34:27 +01:00
|
|
|
|
|
|
|
# Apache + PHP requires preforking Apache for best results
|
|
|
|
RUN a2dismod mpm_event && a2enmod mpm_prefork
|
|
|
|
|
2016-07-07 01:07:32 +02:00
|
|
|
# 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'; \
|
2016-07-08 22:46:02 +02:00
|
|
|
echo; \
|
|
|
|
echo '<Directory /var/www/>'; \
|
|
|
|
echo '\tOptions -Indexes'; \
|
|
|
|
echo '\tAllowOverride All'; \
|
|
|
|
echo '</Directory>'; \
|
2016-07-07 01:07:32 +02:00
|
|
|
} | tee "$APACHE_CONFDIR/conf-available/docker-php.conf" \
|
|
|
|
&& a2enconf docker-php
|
2014-11-07 01:34:27 +01:00
|
|
|
|
|
|
|
ENV PHP_EXTRA_BUILD_DEPS apache2-dev
|
2018-05-22 09:47:57 +02:00
|
|
|
ENV PHP_EXTRA_CONFIGURE_ARGS --with-apxs2 --disable-cgi
|