Answer the question
In order to leave comments, you need to log in
How to activate mod_rewrite in php:7.2-apache in Docker?
There is such a docker-compose.yml file
version: '2.3'
services:
web:
image: php:7.2-apache
ports:
- 8181:80
volumes:
- ./src:/var/www/html
db:
image: mysql:5.7
command: --default-authentication-plugin=mysql_native_password
volumes:
- ./db_data:/var/lib/mysql
ports:
- 3307:3306
environment:
MYSQL_DATABASE: login
MYSQL_USER: login
MYSQL_PASSWORD: root
MYSQL_RANDOM_ROOT_PASSWORD: '1'
phpmyadmin:
depends_on:
- db
image: phpmyadmin/phpmyadmin
ports:
- 8282:80
environment:
PMA_HOST: db
# Включаем mod_rewrite
RewriteEngine On
# Убираем последний слеш
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Преобразуем /pages/about.php в /about
RewriteRule ^(\w+)$ /pages/$1.php [L,NC]
# Dockerfile
FROM php:7.2-apache
RUN a2enmod rewrite
docker-compose up --build
Answer the question
In order to leave comments, you need to log in
If someone has the same question, then here is the solution:
You need to create your own php, apache images via Dockerfile, like this instruction .
In my case, there was also phpmyadmin and some mysql settings for it
This is not ubuntu,
try following
https://stackoverflow.com/questions/49809748/add-m...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question