run php with dedicated user

This commit is contained in:
Paolo Asperti 2024-12-19 08:46:39 +01:00
parent abac3e6949
commit 6aab55295f
Signed by: paspo
GPG Key ID: 06D46905D19D5182
2 changed files with 27 additions and 0 deletions

View File

@ -24,6 +24,10 @@ services:
PUID: 1000 # default: 1000 PUID: 1000 # default: 1000
PGID: 1000 # default: 1000 PGID: 1000 # default: 1000
TZ: Etc/UTC # default: Etc/UTC TZ: Etc/UTC # default: Etc/UTC
FPM_MAX_CHILDREN: 5 # default: 5
FPM_START_SERVERS: 1 # default: 1
FPM_MIN_SPARE_SERVERS: 1 # default: 1
FPM_MAX_SPARE_SERVERS: 3 # default: 3
``` ```
The `/data/www` directory and its contents will be chowned to `$PUID:$PGID` and chmodded to `0755` for directories and `0644` for files at container start. The `/data/www` directory and its contents will be chowned to `$PUID:$PGID` and chmodded to `0755` for directories and `0644` for files at container start.

View File

@ -17,6 +17,29 @@ chown "${PUID}:${GROUPNAME}" "${WEBROOT}" -R
find "${WEBROOT}" -type d -exec chmod 0755 {} \; find "${WEBROOT}" -type d -exec chmod 0755 {} \;
find "${WEBROOT}" -type f -exec chmod 0644 {} \; find "${WEBROOT}" -type f -exec chmod 0644 {} \;
FPM_MAX_CHILDREN=${FPM_MAX_CHILDREN:-5}
FPM_START_SERVERS=${FPM_START_SERVERS:-1}
FPM_MIN_SPARE_SERVERS=${FPM_MIN_SPARE_SERVERS:-1}
FPM_MAX_SPARE_SERVERS=${FPM_MAX_SPARE_SERVERS:-3}
# set php config
case "${PHP}" in
"php84"|"php83"|"php82")
cat >"/etc/${PHP}/php-fpm-d/www.conf" <<EOF
[www]
user = ${USERNAME}
group = ${GROUPNAME}
listen = 127.0.0.1:9000
pm = dynamic
pm.max_children = ${FPM_MAX_CHILDREN}
pm.start_servers = ${FPM_START_SERVERS}
pm.min_spare_servers = ${FPM_MIN_SPARE_SERVERS}
pm.max_spare_servers = ${FPM_MAX_SPARE_SERVERS}
EOF
;;
*) ;;
esac
# start php # start php
case "${PHP}" in case "${PHP}" in
"php84") "php84")