dtwupu6414 2019-07-01 20:34
浏览 175

Docker wordpress-php-fpm-alpine总是给404

I'm following this guide to get a docker-compose setup with multiple Wordpress installations.

When I GET / on the webserver IP address, I get a message stating "File not found."

In the docker logs I see:

wordpress-myclient | 172.20.0.4 -  01/Jul/2019:20:28:37 +0000 "GET /index.php" 404
webserver          | 2019/07/01 20:28:37 [error] 7#7: *23 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: MY_HOME_IP, server: , request: "GET / HTTP/1.1", upstream: "fastcgi://172.20.0.3:9000", host: "THE_SERVER_PUBLIC_IP"
webserver          | MY_HOME_IP - - [01/Jul/2019:20:28:37 +0000] "GET / HTTP/1.1" 404 27 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_4) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.1 Safari/605.1.15" "-"

The root cause appears to be wordpress-myclient having an incorrectly configured php-fpm. I've searched high and low on the documentation for the Wordpress docker image to no avail. I see nothing else in the logs.

Any help is appreciated. Thanks in advance.

docker-compose.yml:

version: '3'

services:
  db:
    image: mariadb/server:latest
    container_name: db
    restart: unless-stopped
    env_file: .env
    volumes:
      - dbdata:/var/lib/mysql
      - ./mysql/init:/docker-entrypoint-initdb.d
    command: '--default-authentication-plugin=mysql_native_password'
    networks:
      - app-network

  wordpress-myclient:
    depends_on:
      - db
    image: wordpress:5-fpm-alpine
    container_name: wordpress-myclient
    restart: unless-stopped
    env_file: .env
    environment:
      - WORDPRESS_DB_HOST=db:3306
      - WORDPRESS_DB_USER=$MYSQL_USER_myclient
      - WORDPRESS_DB_PASSWORD=$MYSQL_PASSWORD_myclient
      - WORDPRESS_DB_NAME=$MYSQL_USER_myclient
    volumes:
      - wordpress-myclient:/var/www/html
    networks:
      - app-network

  webserver:
    depends_on:
      - wordpress-myclient
    image: nginx:1-alpine
    container_name: webserver
    restart: unless-stopped
    ports:
      - "80:80"
      - "443:443"
    environment:
      - NGINX_SERVER_ROOT=/var/www/html
    volumes:
      - wordpress-myclient:/var/www/html/wordpress-myclient
      - ./nginx-conf:/etc/nginx/conf.d
      - certbot-etc:/etc/letsencrypt
    networks:
      - app-network

volumes:
  wordpress-myclient:
  dbdata:
  certbot-etc:

networks:
  app-network:
    driver: bridge

nginx.conf:

server {
        listen 80;
        listen [::]:80;

#        server_name myclient.com www.myclient.com;

        index index.php index.html index.htm;

        root /var/www/html/wordpress-myclient;

        location ~ /.well-known/acme-challenge {
                allow all;
                root /var/www/html/wordpress-myclient;
        }

        location / {
                try_files $uri $uri/ /index.php$is_args$args;
        }

        location ~ \.php$ {
                try_files $uri =404;
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                fastcgi_pass wordpress-myclient: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 ~ /\.ht {
                deny all;
        }

        location = /favicon.ico {
                log_not_found off; access_log off;
        }
        location = /robots.txt {
                log_not_found off; access_log off; allow all;
        }
        location ~* \.(css|gif|ico|jpeg|jpg|js|png)$ {
                expires max;
                log_not_found off;
        }
}
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 无线电能传输系统MATLAB仿真问题
    • ¥50 如何用脚本实现输入法的热键设置
    • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
    • ¥30 深度学习,前后端连接
    • ¥15 孟德尔随机化结果不一致
    • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
    • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
    • ¥15 谁有desed数据集呀
    • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
    • ¥15 关于#hadoop#的问题