Enable mod_headers, Dockerfile - Apache

The following has no effect;

# Dockerfile
FROM php:7-apache

RUN apt-get update && \
 apt-get install -y libxml2-dev && \
 docker-php-ext-install soap

RUN docker-php-ext-install mysqli

# Enable apache mods.
RUN a2enmod php7.0
RUN a2enmod rewrite
RUN a2enmod headers

i.e. the mod_headers module fails to load?

enter image description here

Do you know a way how to install the mod_headers module within Dockerfile ?

I tried;

CMD ["/usr/sbin/apache2", "-D",  "FOREGROUND"]

but then the container wouldn't start.


Add this to your Dockerfile:

RUN cp /etc/apache2/mods-available/rewrite.load /etc/apache2/mods-enabled/ && \
    cp /etc/apache2/mods-available/headers.load /etc/apache2/mods-enabled/

That code will enable mod_rewrite and mod_headers.