Fadly Dzil
Fadly Dzil

Reputation: 2206

Docker-compose : php:7.0-apache , enable mod_rewrite

I want to develop my php app with docker-compose. Here is my docker-compose.yml

version: '3'
services:
  db:
    image: mysql:5.7
    container_name: app_db
    environment:
      MYSQL_ROOT_PASSWORD: secret
    ports:
      - "9906:3306"
  web:
    image: php:7.0-apache
    container_name: app_web
    depends_on:
      - db
    volumes:
    - ./yii2/web/:/var/www/html/
    ports:
      - "8000:80"
    stdin_open: true
    tty: true

The app is running with .htaccess. So, I need to enable mod_rewrite. How to enable this apache configuration ?

 Invalid command 'RewriteEngine', perhaps misspelled or defined by a module not included in the server configuration

Upvotes: 0

Views: 1987

Answers (1)

user18190691
user18190691

Reputation:

Try adding

command: >
  bash -c "a2enmod rewrite
  && apache2-foreground"

Like so:

version: '3'
services:
  db:
    image: mysql:5.7
    container_name: app_db
    environment:
      MYSQL_ROOT_PASSWORD: secret
    ports:
      - "9906:3306"
  web:
    image: php:7.0-apache
    command: >
      bash -c "a2enmod rewrite
      && apache2-foreground"
    container_name: app_web
    depends_on:
      - db
    volumes:
      - ./yii2/web/:/var/www/html/
    ports:
      - "8000:80"
    stdin_open: true
    tty: true

Upvotes: 4

Related Questions