Apache Docker容器-无效的命令'RewriteEngine' [英] Apache docker container - Invalid command 'RewriteEngine'
问题描述
我使用docker compose。但是,当我运行 docker-compose up时,遇到一个错误:/var/www/html/.htaccess:无效的命令'RewriteEngine'。
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 where I fails ??
项目体系结构:
project-name /
/ docker-compose.yml
/ Dockerfile
/ apache.conf
/ php.ini
/ src /
/ index.php
/ .htaccess
docker-compose.yml:
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:
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地址):
apache.conf (with my ip address) :
<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/ ):
and in the browser, in my ip address (http://xxx.xxx.xx.xxx/) :
500 Internal servor error
my .htaccess:
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]
我在Windows上,我使用Oracle VM Virtual Box。
I'm on windows and i use Oracle VM Virtual Box.
预先谢谢您!
编辑:我应该说,如果删除重写规则,一切正常。
EDIT : I should say that if I delete rewrite rules, everything works.
推荐答案
这对我有用:
# Dockerfile
FROM php:5.6-apache
MAINTAINER Raphael Mäder <me@randm.ch>
RUN a2enmod rewrite
ADD . /var/www/html
别忘了运行 docker-如果您以前已经构建了映像,则使用
命令,否则它将运行可能未包含-build
组成 RUN a2enmod rewrite
语句。
这篇关于Apache Docker容器-无效的命令'RewriteEngine'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!