2016-05-06 41 views
6

Uso la finestra mobile comporre. Tuttavia, quando eseguo "docker-compose up", ho trovato un errore: /var/www/html/.htaccess: comando non valido 'RewriteEngine'.Contenitore finestra mobile Apache - Comando non valido 'RewriteEngine'

Puoi dirmi dove fallisco ??

architettura del progetto:

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

finestra mobile-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 (con il mio indirizzo ip):

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

digito nella riga di comando:

[email protected]:/blabla/project-name$ docker-compose up 

mi torna:

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 

e

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

e nel browser, nel mio indirizzo IP (http://xxx.xxx.xx.xxx/):

500 Internal servor error 

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

Sono su Windows e io uso Oracle VM Virtual Box.

Grazie in anticipo!

EDIT: Devo dire che se cancello le regole di riscrittura, tutto funziona.

+0

Provare e rimuovere la riga 'RUN service apache2 restart'. Non si avvia un Apache quando si costruisce un'immagine. – VonC

+0

sempre lo stesso problema. – HeyDaddy

risposta

10

questo funziona per me:

# Dockerfile 
FROM php:5.6-apache 

MAINTAINER Raphael Mäder <[email protected]> 

RUN a2enmod rewrite 

ADD . /var/www/html 

Non dimenticare di eseguire il comando docker-compose up con --build se si è già costruito l'immagine precedentemente, in caso contrario verrà eseguito la vecchia immagine che può non hanno incluso la RUN a2enmod rewrite dichiarazione.

+0

Qualcuno ha capito come si fa da una qualsiasi delle immagini httpd? Sono più interessato ad un'immagine apache + mod_rewrite rispetto ad un'immagine apache + php + mod_rewrite. – Christian