Reputation: 73
I have this Wordpress + PHP project I'm trying to run in Docker containers. The website does work when you visit it in the browser, but it's extremely slow. I tried changing the PHP container port, didn't work. Also tried adding a cache to the PHP Dockerfile, didn't make it any faster. These are the log files:
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
This continues for a while with only 404 errors.
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
edit:
zz-docker.conf:
[global]
daemonize = no
[www]
listen = 9090
Upvotes: 1
Views: 1223
Reputation: 2017
This is not related to docker, the problem is in your configuration of php.
From the documentation, you should use production configuration.
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
From your logs, you should increase pm.max_children in php.ini:
php_1 | [12-Oct-2020 08:04:44] WARNING: [pool www] server reached pm.max_children setting (5), consider raising it
More details here
Upvotes: 2