做个临时站点 从未学过 docker 听说很方便 于是看了几篇网上教程 复制粘贴后稍作修改 目前情况是:docker-compose 能运行, 各容器能运行,网站能打开 phpinfo,phpmyadmin 能连接上 mariadb 。但是安装 wordpress 时,已经用 phpmyadmin 建了数据库和用户授权。但安装页面填好数据库用户名等信息提交后,提示“There has been a critical error on this website.” 哪位能指点下 可能是哪里出问题了?下面是配置文件 不知道有没有写错的地方?
[目录结构]
|—— html
|—— index.php
|—— mariadb
|—— conf.d
|—— db
|—— logs
|—— nginx
|—— conf.d
|—— domain
|fullchain.cer & domain.key
|—— default.conf
|—— logs
|—— nginx.conf
|—— php
|—— logs
|—— Dockerfile
|—— docker-compose.yml
[ Dockerfile ]
FROM php:7.4-fpm-alpine
Run apt install iputils-ping \
&& docker-php-ext-install mysqli && docker-php-ext-enable mysqli && docker-php-ext-install pdo pdo_mysql
[ docker-compose.yml ]
version: '3'
networks:
lnmp-net:
driver: bridge
services:
mariadb:
container_name: mariadb
image: mariadb:10.4
ports:
- 3306:3306
environment:
MYSQL_ROOT_PASSWORD: xxxxxx
volumes:
- /lnmp/mariadb/db:/var/lib/mysql
- /lnmp/mariadb/conf.d:/etc/my.cnf.d
- /lnmp/mariadb/logs:/var/log/mariadb
restart: always
networks:
- lnmp-net
nginx:
container_name: nginx
image: nginx:latest
ports:
- 80:80
- 443:443
volumes:
- /lnmp/html:/usr/share/nginx/html
- /lnmp/nginx/nginx.conf:/etc/nginx/nginx.conf
- /lnmp/nginx/conf.d:/etc/nginx/conf.d
- /lnmp/nginx/logs:/var/log/nginx
depends_on:
- mariadb
- php
restart: always
networks:
- lnmp-net
php:
container_name: php
build: ./php
image: php:7.4-fpm-alpine
ports:
- 9000:9000
volumes:
- /lnmp/html:/var/www/html
- /lnmp/php/php.ini:/usr/local/etc/php/php.ini
- /lnmp/php/logs:/usr/local/var/log
restart: always
networks:
- lnmp-net
phpmyadmin:
container_name: phpmyadmin
image: phpmyadmin/phpmyadmin
ports:
- 2000:80
restart: always
environment:
PMA_HOST: mariadb
networks:
- lnmp-net
[/lnmp/nginx/conf.d/default.conf ]
......
root /usr/share/nginx/html;
index index.html index.htm index.php;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ \.php$ {
fastcgi_pass php:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/html/$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
}
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.