diff --git a/roundcubemail/Dockerfile b/roundcubemail/Dockerfile
index 7b44463..03e6a96 100644
--- a/roundcubemail/Dockerfile
+++ b/roundcubemail/Dockerfile
@@ -1,4 +1,6 @@
FROM debian:buster-20210208-slim
+ENV APACHE_CONFDIR /etc/apache2
+ENV APACHE_ENVVARS $APACHE_CONFDIR/envvars
RUN set -ex; \
apt-get update -qqy; \
apt-get install -qqy --no-install-recommends \
@@ -21,9 +23,45 @@ RUN set -ex; \
libc-l10n \
; \
rm -rf /var/lib/apt/lists/*; \
- a2enmod rewrite; \
+ a2dismod mpm_event && a2enmod mpm_prefork && a2enmod rewrite; \
mkdir -p /etc/ssl/certs; \
- curl -fLSko /etc/ssl/certs/cacert.pem https://curl.se/ca/cacert.pem
+ curl -fLSko /etc/ssl/certs/cacert.pem https://curl.se/ca/cacert.pem; \
+ sed -ri 's/^export ([^=]+)=(.*)$/: ${\1:=\2}\nexport \1/' "$APACHE_ENVVARS"; \
+ \
+ . "$APACHE_ENVVARS"; \
+ for dir in \
+ "$APACHE_LOCK_DIR" \
+ "$APACHE_RUN_DIR" \
+ "$APACHE_LOG_DIR" \
+ ; do \
+ rm -rvf "$dir"; \
+ mkdir -p "$dir"; \
+ chown "$APACHE_RUN_USER:$APACHE_RUN_GROUP" "$dir"; \
+ chmod 777 "$dir"; \
+ done; \
+ \
+ rm -rvf /var/www/html/*; \
+ chmod 777 /var/www/html; \
+ \
+ # 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"; \
+ { \
+ echo ''; \
+ echo '\tSetHandler application/x-httpd-php'; \
+ echo ''; \
+ echo; \
+ echo 'DirectoryIndex disabled'; \
+ echo 'DirectoryIndex index.php index.html'; \
+ echo; \
+ echo ''; \
+ echo '\tOptions -Indexes'; \
+ echo '\tAllowOverride All'; \
+ echo ''; \
+ } | tee "$APACHE_CONFDIR/conf-available/docker-php.conf" \
+ && a2enconf docker-php
ENV CURL_CA_BUNDLE=/etc/ssl/certs/cacert.pem \
SSL_CERT_FILE=/etc/ssl/certs/cacert.pem