gpt4 book ai didi

php - Docker PHP容器抛出20 0's and 404'

转载 作者:行者123 更新时间:2023-12-02 21:31:31 31 4
gpt4 key购买 nike

我有一个要在Docker容器中运行的Wordpress + PHP项目。当您在浏览器中访问该网站时,它确实可以运行,但是速度非常慢。我尝试更改PHP容器端口,但没有用。还尝试将缓存添加到PHP Dockerfile,但并没有使其更快。这些是日志文件:

php_1  | [12-Oct-2020 09:24:13] NOTICE: fpm is running, pid 1
php_1 | [12-Oct-2020 09:24:13] NOTICE: ready to handle connections
web_1 | /docker-entrypoint.sh: Configuration complete; ready for start up
web_1 | 192.168.99.1 - - [12/Oct/2020:09:24:30 +0000] "GET / HTTP/1.1" 200 66467 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.75 Safari/537.36"
web_1 | 192.168.99.1 - - [12/Oct/2020:09:24:30 +0000] "GET /wp/wp-includes/css/dist/block-library/style.min.css?ver=5.5.1 HTTP/1.1" 200 53907 "http://192.168.99.103:8080/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.75 Safari/537.36"
web_1 | 192.168.99.1 - - [12/Oct/2020:09:24:30 +0000] "GET /wp/wp-includes/css/dist/block-library/theme.min.css?ver=5.5.1 HTTP/1.1" 200 2218 "http://192.168.99.103:8080/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.75 Safari/537.36"
web_1 | 192.168.99.1 - - [12/Oct/2020:09:24:30 +0000] "GET /assets/novio/css/tiny-slider.min.css HTTP/1.1" 200 2178 "http://192.168.99.103:8080/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.75 Safari/537.36"
web_1 | 192.168.99.1 - - [12/Oct/2020:09:24:30 +0000] "GET /assets/novio/css/styles.min.css HTTP/1.1" 200 173264 "http://192.168.99.103:8080/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.75 Safari/537.36"
web_1 | 192.168.99.1 - - [12/Oct/2020:09:24:30 +0000] "GET /assets/novio/css/styles-fa.min.css HTTP/1.1" 200 114278 "http://192.168.99.103:8080/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.75 Safari/537.36"
web_1 | 192.168.99.1 - - [12/Oct/2020:09:24:30 +0000] "GET /assets/novio/js/jquery.min.js HTTP/1.1" 200 85578 "http://192.168.99.103:8080/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.75 Safari/537.36"
web_1 | 192.168.99.1 - - [12/Oct/2020:09:24:30 +0000] "GET /assets/novio/js/main.min.js HTTP/1.1" 200 9683 "http://192.168.99.103:8080/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.75 Safari/537.36"
web_1 | 192.168.99.1 - - [12/Oct/2020:09:24:30 +0000] "GET /assets/novio/js/vendor.min.js HTTP/1.1" 200 31966 "http://192.168.99.103:8080/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.75 Safari/537.36"
php_1 | 172.31.0.4 - 12/Oct/2020:09:24:16 +0000 "GET /index.php" 200
web_1 | 192.168.99.1 - - [12/Oct/2020:09:24:50 +0000] "GET /app/uploads/2020/08/00A7580.jpg HTTP/1.1" 404 24328 "http://192.168.99.103:8080/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.75 Safari/537.36"
web_1 | 192.168.99.1 - - [12/Oct/2020:09:24:50 +0000] "GET /app/uploads/2020/09/JEE-O-bloom-setting-3-scaled.jpg HTTP/1.1" 404 24328 "http://192.168.99.103:8080/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.75 Safari/537.36"
php_1 | 172.31.0.4 - 12/Oct/2020:09:24:30 +0000 "GET /index.php" 404
web_1 | 192.168.99.1 - - [12/Oct/2020:09:24:50 +0000] "GET /assets/novio/img/logo-white.svg HTTP/1.1" 200 2519 "http://192.168.99.103:8080/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.75 Safari/537.36"
php_1 | 172.31.0.4 - 12/Oct/2020:09:24:30 +0000 "GET /index.php" 404
web_1 | 192.168.99.1 - - [12/Oct/2020:09:24:50 +0000] "GET /app/uploads/2020/09/JEE-O-pure-setting-01-scaled.jpg HTTP/1.1" 404 16128 "http://192.168.99.103:8080/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.75 Safari/537.36"
php_1 | 172.31.0.4 - 12/Oct/2020:09:24:30 +0000 "GET /index.php" 404
web_1 | 192.168.99.1 - - [12/Oct/2020:09:24:51 +0000] "GET /app/uploads/2020/09/JEE-O-flow-small-setting-02-scaled.jpg HTTP/1.1" 404 16128 "http://192.168.99.103:8080/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.75 Safari/537.36"
php_1 | 172.31.0.4 - 12/Oct/2020:09:24:30 +0000 "GET /index.php" 404
这会持续一段时间,只有404个错误。
docker-compose.yml:
version: '3.1'

services:

web:
image: nginx
volumes:
- ./:/code
- ./docker/nginx/nginx.conf:/etc/nginx/nginx.conf
ports:
- "8080:80"
links:
- php

db:
image: mysql:5.7
restart: always
environment:
- MYSQL_ROOT_PASSWORD=password
- TZ=Europe/Amsterdam
volumes:
- db:/var/lib/mysql
- ./docker/sql:/docker-entrypoint-initdb.d
ports:
- "3306:3306"

php:
build:
context: ./docker/php
ports:
- "9090:9000"
volumes:
- ./:/code
- ./docker/php/zz-docker.conf:/usr/local/etc/php-fpm.d/zz-docker.conf
restart: always


volumes:
wordpress:
db:
nginx.conf:
user  nginx;
worker_processes 1;

error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;


events {
worker_connections 1024;
}

http {

server {

listen 80 default_server;
server_name jeeo.com;
root /code/public_html;
index index.php;
try_files $uri index.php;

location / {
try_files $uri $uri/ /index.php?q=$uri&$args;
}

location ~ \.php$ {

fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass php:9090;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;

}

}

}

PHP Dockerfile:
FROM php:fpm

RUN docker-php-ext-install mysqli
RUN docker-php-ext-install opcache
RUN sed -i 's/9000/9u090/' /usr/local/etc/php-fpm.d/zz-docker.conf
编辑:
zz-docker.conf:
[global]
daemonize = no

[www]
listen = 9090

最佳答案

这与docker不相关,问题出在您的php配置中。
documentation中,您应该使用生产配置。

FROM php:fpm

# Use the default production configuration
RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"

RUN docker-php-ext-install mysqli
RUN docker-php-ext-install opcache
RUN sed -i 's/9000/9u090/' /usr/local/etc/php-fpm.d/zz-docker.conf
从日志中,您应该在php.ini中增加pm.max_children:
php_1  | [12-Oct-2020 08:04:44] WARNING: [pool www] server reached pm.max_children setting (5), consider raising it
更多详细信息 here

关于php - Docker PHP容器抛出20 0's and 404',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64314169/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com