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

发布时间:2022-04-30 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了php – Apache docker container – 无效命令’RewriteEngine’脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
我用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地址):

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

我输入命令行:

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:

<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]

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

先感谢您 !

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

这对我有用:
# Dockerfile
From PHP:5.6-apache

MAINTAINER Raphael Mäder <;me@randm.ch>

RUN a2enmod rewrite

ADD . /var/www/html

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

脚本宝典总结

以上是脚本宝典为你收集整理的php – Apache docker container – 无效命令’RewriteEngine’全部内容,希望文章能够帮你解决php – Apache docker container – 无效命令’RewriteEngine’所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。