[__php_fpm*] add support for Debian and Ubuntu

This commit is contained in:
fnux 2024-05-16 17:05:45 +02:00
parent 116acebd10
commit b7ba43553b
No known key found for this signature in database
GPG key ID: 4502C902C00A1E12
5 changed files with 51 additions and 25 deletions

View file

@ -20,7 +20,7 @@ variables_order = "GPCS"
zend.assertions = -1
; Local custom variations
include_path = ".:/usr/share/php${PHPVER:?}"
include_path = ".:${PHP_INCLUDEDIR}"
memory_limit = ${MEMORY_LIMIT:?}
post_max_size = ${UPLOAD_MAX_FILESIZE:?}
upload_max_filesize = ${UPLOAD_MAX_FILESIZE:?}

View file

@ -12,8 +12,7 @@ This type installs and configures PHP-FPM for a given version of PHP. It is
expected to be used in combination with cdist-type__php_fpm_pool, which
configures specific pools.
Note that currently, this type is only implemented for Alpine Linux.
This type supports Debian, Ubuntu and Alpine Linux.
REQUIRED PARAMETERS
-------------------

View file

@ -6,14 +6,35 @@ PHPVER=$(cat "${__object:?}/parameter/php-version")
export PHPVER
case "$os" in
'alpine')
'alpine')
# Alpine packages looks like php81-fpm - we make sure to remove dots from user
# input.
PHPVER=$(echo "$PHPVER" | tr -d '.')
package="php${PHPVER}-fpm"
service="php-fpm${PHPVER}"
opcache_package="php${PHPVER}-opcache"
apcu_package="php${PHPVER}-pecl-apcu"
;;
*)
service="php-fpm${PHPVER}"
php_confdir="/etc/php${PHPVER}"
php_ini="${php_confdir:?}/php.ini"
PHP_INCLUDEDIR="/usr/share/php${PHPVER:?}"
export PHP_INCLUDEDIR
;;
'debian'|'ubuntu')
package="php${PHPVER}-fpm"
opcache_package="php${PHPVER}-opcache"
apcu_package="php${PHPVER}-apcu"
service="php${PHPVER}-fpm"
php_confdir="/etc/php/${PHPVER}"
php_ini="${php_confdir:?}/fpm/php.ini"
PHP_INCLUDEDIR="/usr/share/php/${PHPVER:?}"
export PHP_INCLUDEDIR
;;
*)
printf "Your operating system is currently not supported by this type\n" >&2
printf "Please contribute an implementation for it if you can.\n" >&2
exit 1
@ -40,8 +61,8 @@ export UPLOAD_MAX_FILESIZE
mkdir -p "${__object:?}/files"
"${__type:?}/files/php.ini.sh" >"${__object:?}/files/php.ini"
require="__package/$package" __file "/etc/php${PHPVER}/php.ini" \
require="__package/$package" __file "${php_ini:?}" \
--mode 644 --source "${__object:?}/files/php.ini" \
--onchange "service $service restart"
require="__file/etc/php${PHPVER}/php.ini" __service "$service" --action start
require="__file/${php_ini:?}" __service "$service" --action start

View file

@ -13,7 +13,7 @@ This type configures a pool named after the `__object_id` for a specified PHP
version. Note that this types expects a same-version cdist-type__php_fpm type
to have been run first: the user is responsible for doing so.
Note that currently, this type is only implemented for Alpine Linux.
This type supports Debian, Ubuntu and Alpine Linux.
REQUIRED PARAMETERS

View file

@ -7,12 +7,18 @@ PHPVER=$(cat "${__object:?}/parameter/php-version")
export PHPVER
case "$os" in
'alpine')
'alpine')
PHPVER=$(echo "$PHP_VERSION" | tr -d '.')
service="php-fpm${PHPVER}"
:
php_confdir="/etc/php${PHPVER}"
php_pooldir="${php_confdir:?}/php-fpm.d"
;;
*)
'debian'|'ubuntu')
service="php${PHPVER}-fpm"
php_confdir="/etc/php/${PHPVER}"
php_pooldir="${php_confdir:?}/fpm/pool.d"
;;
*)
printf "Your operating system is currently not supported by this type\n" >&2
printf "Please contribute an implementation for it if you can.\n" >&2
exit 1
@ -29,6 +35,6 @@ export POOL_USER POOL_GROUP POOL_LISTEN_ADDR POOL_LISTEN_OWNER POOL_NAME
mkdir -p "${__object:?}/files"
"${__type:?}/files/www.conf.sh" >"${__object:?}/files/www.conf"
__file "/etc/php${PHPVER:?}/php-fpm.d/${name}.conf" \
__file "${php_pooldir:?}/${name}.conf" \
--mode 644 --source "${__object:?}/files/www.conf" \
--onchange "service $service reload"