Add php support to nginx

main
Andre Challier 2026-01-11 18:51:18 +01:00
parent 1c7ebb90fd
commit 243c1805e4
2 changed files with 28 additions and 0 deletions

View File

@ -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}

18
nginx.conf Normal file
View File

@ -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;
}
}