水平太差 特来求助 [docker-compose LNMP 数据库连不上] - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
jaleo
V2EX    Docker

水平太差 特来求助 [docker-compose LNMP 数据库连不上]

  •  
  •   jaleo 2021-02-17 18:59:26 +08:00 2019 次点击
    这是一个创建于 1748 天前的主题,其中的信息可能已经有所发展或是发生改变。

    做个临时站点 从未学过 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; } } 
    8 条回复    2021-02-17 22:14:56 +08:00
    foMM
        1
    foMM  
       2021-02-17 19:40:50 +08:00
    nginx 做反代不如试试用 Traefik

    https://www.bilibili.com/video/BV1Pg4y167o9
    Showfom
        2
    Showfom  
    PRO
       2021-02-17 19:43:39 +08:00
    安装 WordPress 的时候,hostname 写 mariadb 镜像的内网 IP 地址试试?
    jaleo
        3
    jaleo  
    OP
       2021-02-17 19:53:56 +08:00
    @Showfom ip 是 172.21.0.2 试了还是一样
    好像网上的教程大多只涉及到上面的程度 看来没有系统性的学习 临时突击真不行
    Yourshell
        4
    Yourshell  
       2021-02-17 20:14:25 +08:00
    wordpress 开 debug 模式看看
    shahaier
        5
    shahaier  
       2021-02-17 20:19:14 +08:00
    使用 mariadb 这个名字试试
    mxalbert1996
        6
    mxalbert1996  
       2021-02-17 20:40:58 +08:00 via Android
    project 内部通信的 host 用 service 名
    jaleo
        7
    jaleo  
    OP
       2021-02-17 21:18:02 +08:00
    @mxalbert1996
    @shahaier
    数据库的 service 名是 mariadb 吗? 创建用户名时 CREATE USER 'user'@'localhost' 这个 localhost 也要用 service 名吗?
    mxalbert1996
        8
    mxalbert1996  
       2021-02-17 22:14:56 +08:00 via Android
    @jaleo 我建议你去读一遍文档看看 @ 后面这个 host 到底是什么意思。另外创建用户一般用环境变量: https://hub.docker.com/_/mariadb
    关于     帮助文档     自助推广系统     博客     API     FAQ     Solana     952 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 23ms UTC 19:19 PVG 03:19 LAX 11:19 JFK 14:19
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86