加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

php – Apache docker container – 无效命令’RewriteEngine

发布时间:2020-12-16 03:44:25 所属栏目:安全 来源:网络整理
导读:我用docker compose.但是,当我运行“docker-compose up”时,我遇到了一个错误:/var/www/html/.htaccess:无效的命令RewriteEngine. 你能告诉我哪里失败了吗? 项目架构: project-name / / docker-compose.yml / Dockerfile / apache.conf / php.ini / src

我用docker compose.但是,当我运行“docker-compose up”时,我遇到了一个错误:/var/www/html/.htaccess:无效的命令’RewriteEngine’.

你能告诉我哪里失败了吗?

项目架构:

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

Dockerfile:

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(带我的IP地址):

我输入命令行:

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

它回报我:

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

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

在浏览器中,在我的IP地址(http://xxx.xxx.xx.xxx/)中:

500 Internal servor error

我的.htaccess:

我在Windows上,我使用Oracle VM Virtual Box.

先感谢您 !

编辑:我应该说,如果我删除重写规则,一切正常.

最佳答案
这对我有用:

# Dockerfile
FROM php:5.6-apache

MAINTAINER Raphael M?der 

如果您之前已经构建了图像,请不要忘记使用–build运行docker-compose up命令,否则它将运行可能未包含RUN a2enmod重写语句的旧图像.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读