Apache Dock Container - Invalid 'RewriteEngine' Command

I am using docker compose. However, when I run "docker-compose up", I came across an error: /var/www/html/.htaccess: Invalid "RewriteEngine" command.

Can you tell me where I am failing?

Project Architecture:

project-name / / docker-compose.yml / Dockerfile / apache.conf / php.ini / src / / index.php / .htaccess 

docker-compose.yml:

 web: build: . ports: - "80:80" volumes: - ./src:/var/www/html - php.ini:/usr/local/etc/php/conf.d/30-custom.ini - apache.conf:/etc/apache2/sites-enabled environment: - ALLOW_OVERRIDE=true 

Docker file:

 FROM php:7.0-apache RUN a2enmod rewrite RUN service apache2 restart ADD ./src /var/www/html 

php.ini:

 display_errors=1 error_reporting=E_ALL 

apache.conf (with my IP address):

 <VirtualHost *:80> ServerName xxx.xxx.xx.xxx DocumentRoot /var/www/html </VirtualHost> 

At the command prompt, type:

 docker@default :/blabla/project-name$ docker-compose up 

he returns me:

 AH00558: apache2: Could not reliably determine the server fully qualified domain name, using xxx.xx.xx Set the 'ServerName' directive globally to suppress this message 

and

 /var/www/html/.htaccess: Invalid command 'RewriteEngine', perhaps misspelled or defined by a module not included in the server configuration 

and in the browser, in my ip-address ( http://xxx.xxx.xx.xxx/ ):

 500 Internal servor error 

my.htaccess:

 <files .htaccess> Require all denied </files> Options +FollowSymlinks -Indexes -Multiviews RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)/$ /$1 [L,R=301] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?p=$1 [L,QSA] 

I am in windows and I am using Virtual VM Virtual Box.

Thank you in advance!

EDIT: I have to say that if I delete the rewrite rules, everything will work.

+6
source share
1 answer

This works for me:

 # Dockerfile FROM php:5.6-apache MAINTAINER Raphael MΓ€der < me@randm.ch > RUN a2enmod rewrite ADD . /var/www/html 

Remember to run the docker-compose up --build with --build if you already created the image earlier, otherwise it will launch an old image that might not have included the RUN a2enmod rewrite .

+10
source

All Articles