Apache docker container - Invalid command 'RewriteEngine'

后端 未结 2 651
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-28 18:58

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

Can you tell me

相关标签:
2条回答
  • 2020-12-28 19:42

    This works for me:

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

    Don't forget to run your docker-compose up command with --build if you have already built the image previously, otherwise it will run the old image which may have not included the RUN a2enmod rewrite statement.

    0 讨论(0)
  • 2020-12-28 19:58

    Add this to your Dockerfile:

    # Enable mod_rewrite for images with apache
    RUN if command -v a2enmod >/dev/null 2>&1; then \
            a2enmod rewrite headers \
        ;fi
    
    0 讨论(0)
提交回复
热议问题