Я пытаюсь создать приложение-докер с Symfony 4, PHP 7.2, MySQL и Apache.Но у меня проблема с маршрутами Symfony, возможно, из-за неправильной конфигурации apache.Я создал TestController с / test route и у меня ошибка 404 not found при попытке перейти на localhost: 8080 / test.Но localhost: 8080 / index.php / test работает.
Спасибо.
Мой файл docker-compose:
version: "3.7"
services:
apache:
container_name: apache
build: ./docker/apache
ports:
- 8080:80
depends_on:
- php
- mysql
volumes:
- .:/var/www/app
mysql:
container_name: mysql
image: mysql
restart: always
volumes:
- ./docker/data/db:/var/lib/mysql
command: --default-authentication-plugin=mysql_native_password
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: app
MYSQL_USER: khan
MYSQL_PASSWORD: khan
php:
container_name: php
build: ./docker/php
working_dir: /var/www/app
volumes:
- .:/var/www/app
Мой app.conf (Apache):
LoadModule deflate_module /usr/local/apache2/modules/mod_deflate.so
LoadModule proxy_module /usr/local/apache2/modules/mod_proxy.so
LoadModule proxy_fcgi_module /usr/local/apache2/modules/mod_proxy_fcgi.so
<VirtualHost *:80>
# Uncomment the following line to force Apache to pass the Authorization
# header to PHP: required for "basic_auth" under PHP-FPM and FastCGI
#
# SetEnvIfNoCase ^Authorization$ "(.+)" HTTP_AUTHORIZATION=$1
# For Apache 2.4.9 or higher
# Using SetHandler avoids issues with using ProxyPassMatch in combination
# with mod_rewrite or mod_autoindex
#<FilesMatch \.php$>
#SetHandler proxy:fcgi://php:9000
# for Unix sockets, Apache 2.4.10 or higher
# SetHandler proxy:unix:/path/to/fpm.sock|fcgi://dummy
#</FilesMatch>
# If you use Apache version below 2.4.9 you must consider update or use this instead
# ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/var/www/project/public/$1
# If you run your Symfony application on a subpath of your document root, the
# regular expression must be changed accordingly:
# ProxyPassMatch ^/path-to-app/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/var/www/project/public/$1
ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://php:9000/var/www/app/public/$1
#<Directory /var/www/app/public>
#AllowOverride All
#Require all granted
#</Directory>
ServerAdmin webmaster@localhost.com
DocumentRoot /var/www/app/public
ServerName dev.app.com
ServerAlias www.dev.app.com
<Directory /var/www/app/public>
# enable the .htaccess rewrites
DirectoryIndex index.php
#Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
# uncomment the following lines if you install assets as symlinks
# or run into problems when compiling LESS/Sass/CoffeeScript assets
# <Directory /usr/local/apache2/htdocs/app/public>
# Options FollowSymlinks
# </Directory>
#<FilesMatch \.php$>
#SetHandler proxy:fcgi://php:9000/var/www/app/public/$1
# for Unix sockets, Apache 2.4.10 or higher
# SetHandler proxy:unix:/path/to/fpm.sock|fcgi://dummy
#</FilesMatch>
ErrorLog /var/log/app_error.log
CustomLog /var/log/app_access.log combined
</VirtualHost>
Мой Apache Dockerfile:
FROM httpd:2.4-alpine
RUN apk update; \
apk upgrade;
COPY app.conf /usr/local/apache2/conf/app.conf
RUN echo "Include /usr/local/apache2/conf/app.conf" \
>> /usr/local/apache2/conf/httpd.conf