From 243c1805e440279c92bea8aa387e8f191af839f2 Mon Sep 17 00:00:00 2001 From: Andre Challier Date: Sun, 11 Jan 2026 18:51:18 +0100 Subject: [PATCH] Add php support to nginx --- docker-compose.yml | 10 ++++++++++ nginx.conf | 18 ++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 nginx.conf diff --git a/docker-compose.yml b/docker-compose.yml index ce3dfbc..8caf376 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,6 +6,15 @@ services: restart: always volumes: - static-files:/usr/share/nginx/html + - ./nginx.conf:/etc/nginx/conf.d/default.conf:ro + networks: + - nginx-network + + php: + image: php:8.2-fpm + restart: always + volumes: + - static-files:/var/www/html # same volume as Nginx networks: - nginx-network @@ -26,6 +35,7 @@ services: volumes: static-files: name: ${STATIC_FILES_VOLUME_NAME} + networks: nginx-network: name: ${NGINX_NETWORK} diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..4bd0cc8 --- /dev/null +++ b/nginx.conf @@ -0,0 +1,18 @@ +server { + listen 80; + server_name localhost; # or your staging domains + + root /usr/share/nginx/html; + index index.php index.html index.htm; + + location / { + try_files $uri $uri/ /index.php?$query_string; + } + + location ~ \.php$ { + include fastcgi_params; + fastcgi_pass php:9000; # points to the PHP-FPM service + fastcgi_index index.php; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + } +}