Update tools.func
This commit is contained in:
parent
48c7d7ee1b
commit
bbae658820
@ -353,6 +353,25 @@ install_mysql() {
|
|||||||
# PHP_MAX_EXECUTION_TIME - (default: 300)
|
# PHP_MAX_EXECUTION_TIME - (default: 300)
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# Installs PHP with selected modules and configures Apache/FPM support.
|
||||||
|
#
|
||||||
|
# Description:
|
||||||
|
# - Adds Sury PHP repo if needed
|
||||||
|
# - Installs default and user-defined modules
|
||||||
|
# - Patches php.ini for CLI, Apache, and FPM as needed
|
||||||
|
#
|
||||||
|
# Variables:
|
||||||
|
# PHP_VERSION - PHP version to install (default: 8.4)
|
||||||
|
# PHP_MODULE - Additional comma-separated modules
|
||||||
|
# PHP_APACHE - Set YES to enable PHP with Apache
|
||||||
|
# PHP_FPM - Set YES to enable PHP-FPM
|
||||||
|
# PHP_MEMORY_LIMIT - (default: 512M)
|
||||||
|
# PHP_UPLOAD_MAX_FILESIZE - (default: 128M)
|
||||||
|
# PHP_POST_MAX_SIZE - (default: 128M)
|
||||||
|
# PHP_MAX_EXECUTION_TIME - (default: 300)
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
install_php() {
|
install_php() {
|
||||||
local PHP_VERSION="${PHP_VERSION:-8.4}"
|
local PHP_VERSION="${PHP_VERSION:-8.4}"
|
||||||
local PHP_MODULE="${PHP_MODULE:-}"
|
local PHP_MODULE="${PHP_MODULE:-}"
|
||||||
@ -379,45 +398,44 @@ install_php() {
|
|||||||
# Deduplicate modules
|
# Deduplicate modules
|
||||||
COMBINED_MODULES=$(echo "$COMBINED_MODULES" | tr ',' '\n' | awk '!seen[$0]++' | paste -sd, -)
|
COMBINED_MODULES=$(echo "$COMBINED_MODULES" | tr ',' '\n' | awk '!seen[$0]++' | paste -sd, -)
|
||||||
|
|
||||||
local CURRENT_PHP
|
local CURRENT_PHP=""
|
||||||
if command -v php >/dev/null 2>&1; then
|
if command -v php >/dev/null 2>&1; then
|
||||||
CURRENT_PHP=$(php -v 2>/dev/null | awk '/^PHP/{print $2}' | cut -d. -f1,2)
|
CURRENT_PHP=$(php -v 2>/dev/null | awk '/^PHP/{print $2}' | cut -d. -f1,2)
|
||||||
else
|
|
||||||
CURRENT_PHP=""
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -z "$CURRENT_PHP" ]]; then
|
if [[ -z "$CURRENT_PHP" ]]; then
|
||||||
msg_info "Setup PHP $PHP_VERSION"
|
msg_info "No PHP found, setting up PHP $PHP_VERSION"
|
||||||
elif [[ "$CURRENT_PHP" != "$PHP_VERSION" ]]; then
|
elif [[ "$CURRENT_PHP" != "$PHP_VERSION" ]]; then
|
||||||
msg_info "PHP $CURRENT_PHP detected, migrating to PHP $PHP_VERSION"
|
msg_info "PHP $CURRENT_PHP detected, migrating to PHP $PHP_VERSION"
|
||||||
if [[ ! -f /etc/apt/sources.list.d/php.list ]]; then
|
|
||||||
$STD curl -fsSLo /tmp/debsuryorg-archive-keyring.deb https://packages.sury.org/debsuryorg-archive-keyring.deb
|
|
||||||
$STD dpkg -i /tmp/debsuryorg-archive-keyring.deb
|
|
||||||
echo "deb [signed-by=/usr/share/keyrings/deb.sury.org-php.gpg] https://packages.sury.org/php/ ${DISTRO_CODENAME} main" \
|
|
||||||
>/etc/apt/sources.list.d/php.list
|
|
||||||
$STD apt-get update
|
|
||||||
fi
|
|
||||||
|
|
||||||
$STD apt-get purge -y "php${CURRENT_PHP//./}"* || true
|
$STD apt-get purge -y "php${CURRENT_PHP//./}"* || true
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Ensure Sury repo is available
|
||||||
|
if [[ ! -f /etc/apt/sources.list.d/php.list ]]; then
|
||||||
|
$STD curl -fsSLo /tmp/debsuryorg-archive-keyring.deb https://packages.sury.org/debsuryorg-archive-keyring.deb
|
||||||
|
$STD dpkg -i /tmp/debsuryorg-archive-keyring.deb
|
||||||
|
echo "deb [signed-by=/usr/share/keyrings/deb.sury.org-php.gpg] https://packages.sury.org/php/ ${DISTRO_CODENAME} main" \
|
||||||
|
>/etc/apt/sources.list.d/php.list
|
||||||
|
$STD apt-get update
|
||||||
|
fi
|
||||||
|
|
||||||
local MODULE_LIST="php${PHP_VERSION}"
|
local MODULE_LIST="php${PHP_VERSION}"
|
||||||
IFS=',' read -ra MODULES <<<"$COMBINED_MODULES"
|
IFS=',' read -ra MODULES <<<"$COMBINED_MODULES"
|
||||||
for mod in "${MODULES[@]}"; do
|
for mod in "${MODULES[@]}"; do
|
||||||
MODULE_LIST+=" php${PHP_VERSION}-${mod}"
|
MODULE_LIST+=" php${PHP_VERSION}-${mod}"
|
||||||
done
|
done
|
||||||
|
|
||||||
if [[ "$PHP_FPM" == "YES" ]]; then
|
if [[ "$PHP_FPM" == "YES" ]]; then
|
||||||
MODULE_LIST+=" php${PHP_VERSION}-fpm"
|
MODULE_LIST+=" php${PHP_VERSION}-fpm"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$PHP_APACHE" == "YES" ]]; then
|
if [[ "$PHP_APACHE" == "YES" ]] && [[ -n "$CURRENT_PHP" ]]; then
|
||||||
# Optionally disable old Apache PHP module
|
|
||||||
if [[ -f /etc/apache2/mods-enabled/php${CURRENT_PHP}.load ]]; then
|
if [[ -f /etc/apache2/mods-enabled/php${CURRENT_PHP}.load ]]; then
|
||||||
$STD a2dismod php${CURRENT_PHP} || true
|
$STD a2dismod php${CURRENT_PHP} || true
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$PHP_FPM" == "YES" ]]; then
|
if [[ "$PHP_FPM" == "YES" ]] && [[ -n "$CURRENT_PHP" ]]; then
|
||||||
$STD systemctl stop php${CURRENT_PHP}-fpm || true
|
$STD systemctl stop php${CURRENT_PHP}-fpm || true
|
||||||
$STD systemctl disable php${CURRENT_PHP}-fpm || true
|
$STD systemctl disable php${CURRENT_PHP}-fpm || true
|
||||||
fi
|
fi
|
||||||
@ -435,8 +453,7 @@ install_php() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Patch all relevant php.ini files
|
# Patch all relevant php.ini files
|
||||||
local PHP_INI_PATHS=()
|
local PHP_INI_PATHS=("/etc/php/${PHP_VERSION}/cli/php.ini")
|
||||||
PHP_INI_PATHS+=("/etc/php/${PHP_VERSION}/cli/php.ini")
|
|
||||||
[[ "$PHP_FPM" == "YES" ]] && PHP_INI_PATHS+=("/etc/php/${PHP_VERSION}/fpm/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")
|
[[ "$PHP_APACHE" == "YES" ]] && PHP_INI_PATHS+=("/etc/php/${PHP_VERSION}/apache2/php.ini")
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user