I’m trying to setup my container for .htaccess & mod_rewrite. But so far my setup doesn’t seem to be working, what am I doing wrong here?
Dockerfile: (note that the last two lines that are commented out fail due to something being wrong with the destination path)
FROM php:8.2-apache
COPY . /var/www/html
COPY ./httpd-vhost.conf /etc/apache/sites_available/
WORKDIR /var/www/html
RUN apt-get update && apt-get install -y \
libfreetype6-dev \
libjpeg62-turbo-dev \
libpng-dev \
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
&& docker-php-ext-install -j$(nproc) gd \
&& docker-php-ext-install pdo_mysql \
&& a2enmod rewrite \
&& pecl install xdebug-3.3.1 && docker-php-ext-enable xdebug
# && sed -i '/LoadModule rewrite_module/s/^#//g' /usr/local/apache2/conf/httpd.conf \
# && sed -i 's#AllowOverride [Nn]one#AllowOverride All#' /usr/local/apache2/conf/httpd.conf
docker-compose.yml:
version: '3.1'
services:
php:
build:
context: .
dockerfile: Dockerfile
volumes:
[./:/var/www/html,
./docker/php/conf.d/php.ini:/usr/local/etc/php/php.ini,
./docker/php/conf.d/xdebug.ini:/usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini,
./docker/php/conf.d/error_reporting.ini:/usr/local/etc/php/conf.d/error_reporting.ini,
./httpd-vhost.conf:/etc/apache2/sites-available/000-default.conf
]
ports:
["8081:80"]
stdin_open: true
tty: true
db:
image: mariadb:10.6
restart: always
volumes:
["./mariadb/data:/var/lib/mysql"]
ports:
["3306:3306"]
environment:
DATASOURCES_DEFAULT_HOST: db
MYSQL_ROOT_PASSWORD: notSecureChangeMe
MYSQL_USER: product_db_user
MYSQL_PASSWORD: secret
phpmyadmin:
image: phpmyadmin
restart: always
ports:
- 8082:80
environment:
- PMA_ARBITRARY=1
.htaccess:
RewriteEngine On
RewriteRule ^ index.php
httpd-vhost.conf:
<VirtualHost *:80>
ServerName phpmvc.localhost
ServerAlias phpmvc.localhost
RewriteEngine On
RewriteRule ^ index.php
DocumentRoot "/var/www/html"
<Directory "/var/www/html">
Require all granted
AllowOverride All
</Directory>
</VirtualHost>