I tried add PHP 8 to my docker project but can’t run it. My error maybe in nginx config file.
File docker-compose.yml
:
version: "3.7"
services:
phpfpm:
image: php:8.0.2-fpm-alpine3.13
container_name: phpfpm
volumes:
- ./php/src:/var/www/html
- ./php/config/php.ini:/usr/local/etc/php/conf.d/php.ini
networks:
- Project
nginx:
image: nginx:latest
container_name: proxy_nginx
restart: always
ports:
- "8888:8888"
- "9999:9999"
- "5555:5555"
volumes:
- ./nginx/nginx.conf:/etc/nginx/nginx.conf
- ./nginx/logs:/var/log/nginx/
- ./php/src:/var/www/html
depends_on:
- grafana
- clickhouse
- phpfpm
networks:
- Project
clickhouse:
container_name: clickhouse
image: yandex/clickhouse-server
volumes:
- ./clickhouse/data:/var/lib/clickhouse:rw
- /var/log/clickhouse-server
- ./clickhouse/init_schema.sql:/docker-entrypoint-initdb.d/init_schema.sql
# - ./clickhouse/config.xml:/etc/clickhouse-server/config.xml
networks:
- Project
grafana:
container_name: grafana
image: grafana/grafana
volumes:
- ./grafana:/var/lib/grafana:rw
- ./grafana/grafana-clickhouse-datasource.yaml:/etc/grafana/provisioning/datasources/grafana-clickhouse-datasource.yaml
- ./grafana/grafana-dashboards.yaml:/etc/grafana/provisioning/dashboards/grafana-dashboards.yaml
- ./grafana/dashboards/:/var/lib/grafana/dashboards/
environment:
- GF_PLUGINS_ALLOW_LOADING_UNSIGNED_PLUGINS=vertamedia-clickhouse-datasource
- GF_INSTALL_PLUGINS=grafana-piechart-panel,grafana-worldmap-panel,vertamedia-clickhouse-datasource
depends_on:
- clickhouse
networks:
- Project
networks:
Project:
driver: bridge
Nginx config file:
user www-data;
worker_processes 1;
pid /var/run/nginx.pid;
worker_rlimit_nofile 4096;
events {
multi_accept on;
use epoll;
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
error_log syslog:server=127.0.0.1:8000;
# error_log /var/log/nginx/error.log warn;
# access_log /var/log/nginx/access.log;
access_log syslog:server=127.0.0.1:8000;
open_file_cache max=5000 inactive=20s;
open_file_cache_valid 30s;
open_file_cache_min_uses 2;
open_file_cache_errors on;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
server_tokens off;
types_hash_max_size 2048;
keepalive_requests 1000;
keepalive_timeout 5;
server_names_hash_max_size 512;
server_names_hash_bucket_size 64;
client_max_body_size 100m;
client_body_buffer_size 256k;
reset_timedout_connection on;
client_body_timeout 10;
send_timeout 2;
gzip on;
gzip_static on;
gzip_comp_level 5;
gzip_min_length 256;
gzip_http_version 1.1;
gzip_proxied any;
gzip_vary on;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript text/x-js;
gzip_disable "msie6";
proxy_max_temp_file_size 0;
upstream proj {
server clickhouse:8123;
}
upstream grafana {
server grafana:3000;
}
server {
listen 8888;
server_name 127.0.0.1;
root /var/www;
proxy_set_header Host $host;
location / {
proxy_pass http://proj;
proxy_set_header Host $host;
add_header Cache-Control "no-cache" always;
}
}
server {
listen 9999;
server_name 127.0.0.1;
root /var/www;
proxy_set_header Host $host;
location / {
proxy_pass http://grafana;
proxy_set_header Host $host;
add_header Cache-Control "no-cache" always;
}
}
server {
listen 5555;
server_name 127.0.0.1;
index index.php index.html;
root /var/www/html;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ .php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+.php)(/.+)$;
fastcgi_pass phpfpm:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
}
}
In my case grafana and clickhouse works. But phpfpm doesn’t works. How I can fix nginx config in this case? Maybe also I must use upstream for phpfpm in this case?
2
Answers
it seems that the Nginx file does not contain any reference to the yaml one, check if the yaml extension is working in php 8 and check also which is the file that parse the yaml document.
try running this code:
Make sure your php-fpm is running. and Also replace fastcgi_pass phpfpm:9000 with fastcgi_pass 127.0.0.1:9000.
See the article: How to setup PHP 8, NGINX, PHP-FPM and Alpine with Docker