Tengo dos contenedores acoplables para php-fpm y nginx, los ejecuto con el archivo docker-compose.yml, pero intento configurar la página de estado de mi php-fpm y no se encuentra.
tengo acceso ahttp://localhost/estadoURL y muestra el mensaje Archivo no encontrado.
Probé demasiadas configuraciones pero no funciona.
mi árbol directo es este:
C:.
│ docker-compose.yml
│
├───app
│ index.php
│
├───fpmConf
│ www.conf
│
├───nginxConf
│ default.conf
│
└───phpConf
php.ini
mi archivo docker-compose.yml es:
version: '3'
services:
php:
image: php:7.2-fpm
container_name: php_app
restart: always
environment:
TZ: America/Mexico_City
ports:
- 9000:9000
volumes:
- ./app:/var/www/html
- ./phpConf/php.ini:/usr/local/etc/php/conf.d/custom.ini
tty: true
nginx:
image: nginx:latest
container_name: nginx_proxy
restart: always
environment:
TZ: America/Mexico_City
ports:
- 80:80
links:
- php
volumes:
- ./app:/var/www/html
- ./nginxConf:/etc/nginx/conf.d
- ./fpmConf/www.conf:/etc/php-fpm.d/www.conf
depends_on:
- php
tty: true
mi archivo www.conf es:
user = www
listen = php:9000
pm = ondemand
pm.max_children = 50
pm.max_requests = 500
pm.process_idle_timeout = 10s
pm.status_path = /status
ping.path = /ping
slowlog = /data/logs/php-fpm-slow.log
request_slowlog_timeout = 60
catch_workers_output = yes
env[TMPDIR] = /data/tmp/php
include = /data/conf/php-fpm-www-*.conf
mi archivo default.conf es:
upstream php-upstream {
server php:9000;
}
server {
server_tokens off;
charset utf-8;
client_max_body_size 128M;
proxy_buffer_size 128k;
proxy_buffers 4 256k;
proxy_busy_buffers_size 256k;
listen 80;
server_name localhost;
# set caching header for static files
location ~* \.(jpg|jpeg|gif|png|css|js|ico|svg|ttf|webp)$ {
access_log off;
log_not_found off;
expires 30d;
}
root /var/www/html;
index index.php;
location / {
try_files $uri $uri/ /index.php$is_args$args;
location ~ \.php$ {
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
if (!-f $document_root$fastcgi_script_name) {
return 404;
}
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_pass php:9000;
fastcgi_index index.php;
fastcgi_pass_header Set-Cookie;
fastcgi_pass_header Cookie;
fastcgi_ignore_headers Cache-Control Expires Set-Cookie;
}
}
location /status {
access_log off;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass php-upstream;
fastcgi_index status.html;
}
}
mi archivo php.ini es:
date.timezone = "America/Mexico_City"
default_charset = "utf-8";
mbstring.internal_encoding=utf-8;
mbstring.http_output=UTF-8;
mbstring.encoding_translation=On;
session.use_cookies = 1
session.name = PHPSESSID
session.cookie_lifetime = 0
session.cookie_path = /
session.cookie_domain = alocalhost
session.serialize_handler = php
session.gc_maxlifetime = 86400
max_input_vars = 1000000
Respuesta1
Lo resolví copiando desde el contenedor el archivo www.conf a mi host:
docker cp -a php_app:/usr/local/etc/php-fpm.d/www.conf ./www.conf
Luego descomento esta línea y comparto este nuevo archivo www.conf con Docker:
pm.status_path = /status
Este es mi nuevo docker-compose.yml con el nuevo volumen con www.conf./status/www.conf:/usr/local/etc/php-fpm.d/www.conf:
version: '3'
services:
php:
image: php:7.2-fpm
container_name: php_app
restart: always
environment:
TZ: America/Mexico_City
ports:
- 9000:9000
volumes:
- ./app:/var/www/html
- ./phpConf/php.ini:/usr/local/etc/php/conf.d/custom.ini
- ./status/www.conf:/usr/local/etc/php-fpm.d/www.conf
tty: true
nginx:
image: nginx:latest
container_name: nginx_proxy
restart: always
environment:
TZ: America/Mexico_City
ports:
- 80:80
links:
- php
volumes:
- ./app:/var/www/html
- ./nginxConf:/etc/nginx/conf.d
- ./fpmConf/www.conf:/etc/php-fpm.d/www.conf
depends_on:
- php
tty: true