Drop php.ini variable (disable_functions) to fpm pool.d conf level
Posted: Mon Apr 03, 2023 2:09 pm
Let's say you want to drop 'disable_functions' php.ini variable to fpm pool.d conf level, so every domain has its own value for 'disable_functions'.
In your SSH, as root, run:
This is example for PHP 7.4, so change first two lines for other PHP versions.
In your SSH, as root, run:
Code: Select all
phpver='7.4'
PHPINIVAR='disable_functions'
phpvert=$(echo $phpver | sed "s|\.||g")
PHPINIVAL=$(grep "^$PHPINIVAR" /etc/php/$phpver/fpm/php.ini | awk '{print $3}')
OLDVAL='php_admin_value\[sendmail_path\]'
NEWVAL="php_admin_value\[disable_functions\] = \\\\\"$PHPINIVAL\\\\\"\nphp_admin_value\[sendmail_path\]"
NEWVALPOOLD="php_admin_value\[disable_functions\] = \\\"$PHPINIVAL\\\"\nphp_admin_value\[sendmail_path\]"
grep -L "$PHPINIVAR" /usr/local/vesta/data/templates/web/apache2/PHP-FPM-$phpvert.sh | xargs sed -i "s|$OLDVAL|$NEWVAL|g"
find /etc/php/$phpver/fpm/pool.d/ -name "*.conf" -type f -exec grep -L "$PHPINIVAR" {} \; | xargs sed -i "s|$OLDVAL|$NEWVALPOOLD|g"
sed -i "s|^$PHPINIVAR|; $PHPINIVAR|g" /etc/php/$phpver/fpm/php.ini
service php$phpver-fpm restart