Skip to content

Commit f702a79

Browse files
committed
Allow setting PHP-FPM user/group with env var
1 parent a7b3708 commit f702a79

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,10 @@ For help running these locally with docker run see the [docker run reference](ht
3737
| ATATUS_APM_LICENSE_KEY | Your Atatus license key. Atatus won't be used if this is not set. ||||
3838
| ATATUS_APM_RAW_SQL | Set to any value (1, true, etc) to use raw sql logging into Atatus ||||
3939
| PHP_MEMORY_MAX | Maximum PHP request memory, in megabytes (i.e. '256'). Defaults to 128. ||||
40-
| MAX_EXECUTION_TIME | Maximum PHP and Nginx execution/fastcgi read timeout ||||
40+
| MAX_EXECUTION_TIME | Maximum PHP and Nginx execution/fastcgi read timeout ||||
4141
| PHP_FPM_WORKERS | Maximum PHP-FPM workers. Defaults to 4 if not set. ||||
42+
| PHP_FPM_USER | User which PHP-FPM workers are started as. Defaults to nobody. ||||
43+
| PHP_FPM_GROUP | Group which PHP-FPM workers are started as. Defaults to nobody. ||||
4244
| DISABLE_OPCACHE | Set to any value (1, true, etc) to disable PHP Opcache ||||
4345
| PHP_OPCACHE_MEMORY | Maximum PHP request memory, in megabytes (i.e. '64'). Defaults to 16. ||||
4446
| PHP_SESSION_STORE | If not set, PHP uses /tmp for sessions. If set to 'redis', uses redis for sessions ||||

README.md.template

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,10 @@ For help running these locally with docker run see the [docker run reference](ht
3737
| ATATUS_APM_LICENSE_KEY | Your Atatus license key. Atatus won't be used if this is not set. | ✖ | ✓ | ✓ |
3838
| ATATUS_APM_RAW_SQL | Set to any value (1, true, etc) to use raw sql logging into Atatus | ✖ | ✓ | ✓ |
3939
| PHP_MEMORY_MAX | Maximum PHP request memory, in megabytes (i.e. '256'). Defaults to 128. | ✖ | ✓ | ✓ |
40-
| MAX_EXECUTION_TIME | Maximum PHP and Nginx execution/fastcgi read timeout | ✖ | ✓ | ✓ |
40+
| MAX_EXECUTION_TIME | Maximum PHP and Nginx execution/fastcgi read timeout | ✖ | ✓ | ✓ |
4141
| PHP_FPM_WORKERS | Maximum PHP-FPM workers. Defaults to 4 if not set. | ✖ | ✓ | ✖ |
42+
| PHP_FPM_USER | User which PHP-FPM workers are started as. Defaults to nobody. | ✖ | ✓ | ✖ |
43+
| PHP_FPM_GROUP | Group which PHP-FPM workers are started as. Defaults to nobody. | ✖ | ✓ | ✖ |
4244
| DISABLE_OPCACHE | Set to any value (1, true, etc) to disable PHP Opcache | ✖ | ✓ | ✓ |
4345
| PHP_OPCACHE_MEMORY | Maximum PHP request memory, in megabytes (i.e. '64'). Defaults to 16. | ✖ | ✓ | ✓ |
4446
| PHP_SESSION_STORE | If not set, PHP uses /tmp for sessions. If set to 'redis', uses redis for sessions | ✖ | ✓ | ✓ |

php/scripts/configure.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,26 @@ if [ ! -z "$PHP_FPM_WORKERS" ]; then
188188

189189
fi
190190

191+
# PHP-FPM Worker User
192+
# If set
193+
if [ ! -z "$PHP_FPM_USER" ]; then
194+
# Set PHP.ini accordingly
195+
sed -i -e "s#user = nobody#user = $PHP_FPM_USER#g" /etc/php/current/php-fpm.d/www.conf
196+
197+
# Set PHP.ini accordingly
198+
sed -i -e "s#listen.owner = nobody#listen.owner = $PHP_FPM_USER#g" /etc/php/current/php-fpm.d/www.conf
199+
fi
200+
201+
# PHP-FPM Worker Group
202+
# If set
203+
if [ ! -z "$PHP_FPM_GROUP" ]; then
204+
# Set PHP.ini accordingly
205+
sed -i -e "s#group = nobody#group = $PHP_FPM_GROUP#g" /etc/php/current/php-fpm.d/www.conf
206+
207+
# Set PHP.ini accordingly
208+
sed -i -e "s#listen.group = nobody#listen.group = $PHP_FPM_GROUP#g" /etc/php/current/php-fpm.d/www.conf
209+
fi
210+
191211
printf "\e[94m%-30s\e[0m \e[35m%-30s\e[0m\n" "PHP-FPM Max Workers:" "`cat /etc/php/current/php-fpm.d/www.conf | grep 'pm.max_children = ' | sed -e 's/pm.max_children = //g'`"
192212

193213
# Enable short tags for older sites

0 commit comments

Comments
 (0)