forked from forkanization/Proxmox-arm64
Merge remote-tracking branch 'upstream/main'
This commit is contained in:
+42
-29
@@ -396,9 +396,10 @@ function setup_php() {
|
||||
COMBINED_MODULES="${DEFAULT_MODULES}"
|
||||
fi
|
||||
|
||||
# Deduplicate modules
|
||||
# Deduplicate
|
||||
COMBINED_MODULES=$(echo "$COMBINED_MODULES" | tr ',' '\n' | awk '!seen[$0]++' | paste -sd, -)
|
||||
|
||||
# Get current PHP-CLI version
|
||||
local CURRENT_PHP=""
|
||||
if command -v php >/dev/null 2>&1; then
|
||||
CURRENT_PHP=$(php -v 2>/dev/null | awk '/^PHP/{print $2}' | cut -d. -f1,2)
|
||||
@@ -420,53 +421,44 @@ function setup_php() {
|
||||
$STD apt-get update
|
||||
fi
|
||||
|
||||
# Build module list
|
||||
local MODULE_LIST="php${PHP_VERSION}"
|
||||
for pkg in $MODULE_LIST; do
|
||||
if ! apt-cache show "$pkg" >/dev/null 2>&1; then
|
||||
msg_error "Package not found: $pkg"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
IFS=',' read -ra MODULES <<<"$COMBINED_MODULES"
|
||||
for mod in "${MODULES[@]}"; do
|
||||
MODULE_LIST+=" php${PHP_VERSION}-${mod}"
|
||||
if apt-cache show "php${PHP_VERSION}-${mod}" >/dev/null 2>&1; then
|
||||
MODULE_LIST+=" php${PHP_VERSION}-${mod}"
|
||||
else
|
||||
msg_warn "PHP-Module ${mod} for PHP ${PHP_VERSION} not found – skipping"
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ "$PHP_FPM" == "YES" ]]; then
|
||||
MODULE_LIST+=" php${PHP_VERSION}-fpm"
|
||||
fi
|
||||
|
||||
# install apache2 with PHP support if requested
|
||||
if [[ "$PHP_APACHE" == "YES" ]]; then
|
||||
$STD apt-get install -y apache2 libapache2-mod-php${PHP_VERSION}
|
||||
$STD systemctl restart apache2 || true
|
||||
fi
|
||||
|
||||
if [[ "$PHP_APACHE" == "YES" ]] && [[ -n "$CURRENT_PHP" ]]; then
|
||||
if [[ -f /etc/apache2/mods-enabled/php${CURRENT_PHP}.load ]]; then
|
||||
$STD a2dismod php${CURRENT_PHP} || true
|
||||
if ! dpkg -l | grep -q "libapache2-mod-php${PHP_VERSION}"; then
|
||||
msg_info "Installing Apache with PHP${PHP_VERSION} support"
|
||||
$STD apt-get install -y apache2 libapache2-mod-php${PHP_VERSION}
|
||||
else
|
||||
msg_info "Apache with PHP${PHP_VERSION} already installed – skipping install"
|
||||
fi
|
||||
$STD a2enmod php${PHP_VERSION}
|
||||
$STD systemctl restart apache2 || true
|
||||
fi
|
||||
|
||||
if [[ "$PHP_FPM" == "YES" ]] && [[ -n "$CURRENT_PHP" ]]; then
|
||||
$STD systemctl stop php${CURRENT_PHP}-fpm || true
|
||||
$STD systemctl disable php${CURRENT_PHP}-fpm || true
|
||||
fi
|
||||
|
||||
# setup / update PHP modules
|
||||
$STD apt-get install -y $MODULE_LIST
|
||||
msg_ok "Setup PHP $PHP_VERSION"
|
||||
|
||||
if [[ "$PHP_FPM" == "YES" ]]; then
|
||||
$STD systemctl enable php${PHP_VERSION}-fpm
|
||||
$STD systemctl restart php${PHP_VERSION}-fpm
|
||||
# optional stop old PHP-FPM service
|
||||
if [[ "$PHP_FPM" == "YES" && -n "$CURRENT_PHP" && "$CURRENT_PHP" != "$PHP_VERSION" ]]; then
|
||||
$STD systemctl stop php"${CURRENT_PHP}"-fpm || true
|
||||
$STD systemctl disable php"${CURRENT_PHP}"-fpm || true
|
||||
fi
|
||||
|
||||
# Patch all relevant php.ini files
|
||||
local PHP_INI_PATHS=("/etc/php/${PHP_VERSION}/cli/php.ini")
|
||||
[[ "$PHP_FPM" == "YES" ]] && PHP_INI_PATHS+=("/etc/php/${PHP_VERSION}/fpm/php.ini")
|
||||
[[ "$PHP_APACHE" == "YES" ]] && PHP_INI_PATHS+=("/etc/php/${PHP_VERSION}/apache2/php.ini")
|
||||
|
||||
for ini in "${PHP_INI_PATHS[@]}"; do
|
||||
if [[ -f "$ini" ]]; then
|
||||
$STD msg_info "Patching $ini"
|
||||
@@ -477,8 +469,29 @@ function setup_php() {
|
||||
$STD msg_ok "Patched $ini"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# patch Apache configuration if needed
|
||||
if [[ "$PHP_APACHE" == "YES" ]]; then
|
||||
for mod in $(ls /etc/apache2/mods-enabled/ 2>/dev/null | grep -E '^php[0-9]\.[0-9]\.conf$' | sed 's/\.conf//'); do
|
||||
if [[ "$mod" != "php${PHP_VERSION}" ]]; then
|
||||
$STD a2dismod "$mod" || true
|
||||
fi
|
||||
done
|
||||
$STD a2enmod mpm_prefork
|
||||
$STD a2enmod "php${PHP_VERSION}"
|
||||
$STD systemctl restart apache2 || true
|
||||
fi
|
||||
|
||||
# enable and restart PHP-FPM if requested
|
||||
if [[ "$PHP_FPM" == "YES" ]]; then
|
||||
if systemctl list-unit-files | grep -q "php${PHP_VERSION}-fpm.service"; then
|
||||
$STD systemctl enable php${PHP_VERSION}-fpm
|
||||
$STD systemctl restart php${PHP_VERSION}-fpm
|
||||
else
|
||||
msg_warn "FPM requested but service php${PHP_VERSION}-fpm not found"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
# ------------------------------------------------------------------------------
|
||||
# Installs or updates Composer globally.
|
||||
#
|
||||
|
||||
Reference in New Issue
Block a user