我正在尝试使用docker将phpMyAdmin添加到我的LEMP堆栈中,但我无法使其正常工作,
我在另一个容器中使用nginx-proxy,这就是为什么我指定VIRTUAL_HOST并仅公开端口80 并且主页可以正常工作。
我仅收到“找不到文件”错误,并且我已经用多种不同的配置进行了测试,但是没有任何效果,而且我对NGINX的配置也不是很好。
这是我的docker-compose.yml:
version: '3'
services:
php:
build:
context: ./docker
dockerfile: php.Dockerfile
container_name: ${APP_NAME}-php
networks:
- backend
volumes:
- './app:/var/www/html'
- 'phpmyadmin_data:/var/www/html/phpmyadmin:ro'
depends_on:
- mariadb
nginx:
image: nginx:latest
container_name: ${APP_NAME}-nginx
networks:
- frontend
- backend
expose:
- 80
- 443
environment:
VIRTUAL_HOST: ${VIRTUAL_HOST}
links:
- 'php'
- 'phpmyadmin'
volumes:
- './app:/var/www/html:ro'
- 'phpmyadmin_data:/var/www/html/phpmyadmin:ro'
- './config/nginx:/etc/nginx/conf.d:ro'
depends_on:
- php
mariadb:
image: mariadb:10.3.9
container_name: ${APP_NAME}-mariadb
restart: 'on-failure'
networks:
- backend
environment:
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
volumes:
- ${PWD}
phpmyadmin:
image: phpmyadmin/phpmyadmin:fpm-alpine
container_name: ${APP_NAME}-phpmyadmin
networks:
- backend
volumes:
- 'phpmyadmin_data:/var/www/html'
environment:
PMA_HOST: mariadb
depends_on:
- mariadb
volumes:
phpmyadmin_data:
networks:
frontend:
external:
name: 'frontend'
backend: {}
这是我的nginx.conf:
server {
index index.php index.html;
server_name localhost;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
root /var/www/html;
location / {
try_files $uri $uri/ /index.php$is_args$query_string;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass php:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
location /phpmyadmin {
fastcgi_pass phpmyadmin:9000;
fastcgi_index index.php;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
}