Added alternative php. Part 8
This commit is contained in:
@@ -5,6 +5,7 @@ All notable changes to this project will be documented in this file.
|
||||
## [1.9.5.rpm] - Release
|
||||
|
||||
- Added support installation of alternative php not only remi
|
||||
- Fixed separate edition of php.ini in multiphp mode
|
||||
|
||||
## [1.9.4.rpm] - Release
|
||||
|
||||
|
||||
@@ -22,11 +22,11 @@ source $HESTIA/func/main.sh
|
||||
source_conf "$HESTIA/conf/hestia.conf"
|
||||
source_conf "$HESTIA/install/upgrade/upgrade.conf"
|
||||
|
||||
if [ -f /etc/redhat-release ]; then
|
||||
for elem in "${!multiphp_v[@]}"; do
|
||||
multiphp_v[$elem]=$(convert_dot_version_to_non_dot "${multiphp_v[$elem]}")
|
||||
done
|
||||
fi
|
||||
|
||||
for elem in "${!multiphp_v[@]}"; do
|
||||
multiphp_v[$elem]=$(convert_dot_version_to_non_dot "${multiphp_v[$elem]}")
|
||||
done
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Verifications #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
@@ -50,7 +50,7 @@ else
|
||||
fi
|
||||
|
||||
if [ "$LOCAL_PHP" == "yes" ]; then
|
||||
rm -f /opt/brepo/php*/etc/php-fpm.d/
|
||||
rm -f /opt/brepo/php*/etc/php-fpm.d/www.conf
|
||||
cp -f $HESTIA/install/rpm/php-fpm/www.conf /opt/brepo/php${version}/etc/php-fpm.d/www.conf
|
||||
else
|
||||
rm -f /etc/opt/remi/php*/php-fpm.d/www.conf
|
||||
|
||||
@@ -40,6 +40,28 @@ check_hestia_demo_mode
|
||||
#----------------------------------------------------------#
|
||||
# Action #
|
||||
#----------------------------------------------------------#
|
||||
php_v="82"
|
||||
if [[ "$service" =~ ^php ]];then
|
||||
ver_php=$(echo "$service" | grep -Po "\d+")
|
||||
if [ -z "$ver_php" ]; then
|
||||
php_v=$(get_system_default_php)
|
||||
else
|
||||
if [ "$LOCAL_PHP" == "yes" ]; then
|
||||
if [ -e "/opt/brepo/php${ver_php}" ]; then
|
||||
php_v="$ver_php"
|
||||
else
|
||||
php_v=$(get_system_default_php)
|
||||
fi
|
||||
else
|
||||
if [ -e "/etc/opt/remi/php${ver_php}" ]; then
|
||||
php_v="$ver_php"
|
||||
else
|
||||
php_v=$(get_system_default_php)
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
service="php"
|
||||
fi
|
||||
|
||||
# Defining dst config path
|
||||
case $service in
|
||||
@@ -50,7 +72,13 @@ case $service in
|
||||
exim4) dst='/etc/exim4/exim4.conf.template' ;;
|
||||
vsftpd) dst=$(find /etc/vsftpd* -name 'vsftpd.conf') ;;
|
||||
proftpd) dst=$(find /etc/proftpd* -name 'proftpd.conf') ;;
|
||||
php) dst=$(find /etc/php* -name php.ini) ;;
|
||||
php)
|
||||
if [ "$LOCAL_PHP" == "yes" ]; then
|
||||
dst=$(find /opt/brepo/php${php_v} -name php.ini)
|
||||
else
|
||||
dst=$(find /etc/opt/remi/php${php_v} -name php.ini)
|
||||
fi
|
||||
;;
|
||||
mysql) dst=$(find /etc/my* -name my.cnf) ;;
|
||||
mysqld) dst=$(find /etc/my* -name my.cnf) ;;
|
||||
mariadb) dst=$(find /etc/my* -name my.cnf) ;;
|
||||
@@ -103,7 +131,7 @@ if [ "$update" = 'yes' ] && [ "$restart" != 'no' ]; then
|
||||
if [ "$service" = 'php' ]; then
|
||||
if [ "$(multiphp_count)" -gt 0 ]; then
|
||||
service="php-fpm"
|
||||
elif [ "$WEB_SYSTEM" = 'apache2' ]; then
|
||||
elif [ "$WEB_SYSTEM" = 'httpd' ]; then
|
||||
service="$WEB_SYSTEM"
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
# info: list php config parameters
|
||||
# options: [FORMAT]
|
||||
# options: [VERSION] [FORMAT]
|
||||
#
|
||||
# example: v-list-sys-php-config
|
||||
#
|
||||
@@ -11,7 +11,8 @@
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument definition
|
||||
format=${1-shell}
|
||||
php_ver=${1-default}
|
||||
format=${2-shell}
|
||||
|
||||
# Includes
|
||||
# shellcheck source=/etc/hestiacp/hestia.conf
|
||||
@@ -61,12 +62,40 @@ csv_list() {
|
||||
#----------------------------------------------------------#
|
||||
# Action #
|
||||
#----------------------------------------------------------#
|
||||
declare -a versions
|
||||
if [ "$php_ver" == "default" ]; then
|
||||
# List through /etc/php
|
||||
if [ "$LOCAL_PHP" == "yes" ]; then
|
||||
for version in /opt/brepo/php*/etc/php-fpm.d/www.conf; do
|
||||
ver=$(echo "$version" | awk -F"/" '{ print $4 }' | sed "s/php\([[:digit:]]\+\)/\1/g")
|
||||
if [ "$ver" != "php*" ]; then
|
||||
versions+=("$ver")
|
||||
fi
|
||||
done
|
||||
else
|
||||
for version in /etc/opt/remi/php*/php-fpm.d/www.conf; do
|
||||
ver=$(echo "$version" | awk -F"/" '{ print $5 }' | sed "s/php\([[:digit:]]\+\)/\1/g")
|
||||
if [ "$ver" != "php*" ]; then
|
||||
versions+=("$ver")
|
||||
fi
|
||||
done
|
||||
fi
|
||||
else
|
||||
ver=$(echo "$php_ver" | sed "s/php\([[:digit:]]\+\)/\1/g")
|
||||
versions+=("$ver")
|
||||
fi
|
||||
|
||||
if [ ${#versions[@]} -eq 0 ]; then
|
||||
php_ver="82"
|
||||
else
|
||||
php_ver="${versions[0]}"
|
||||
fi
|
||||
|
||||
# Defining config path
|
||||
if [ "$LOCAL_PHP" == "yes" ]; then
|
||||
config_path=$(find /opt/brepo/php* -name php.ini)
|
||||
config_path=$(find /opt/brepo/php${php_ver}/* -name php.ini)
|
||||
else
|
||||
config_path=$(find /etc/opt/remi/php* -name php.ini)
|
||||
config_path=$(find /etc/opt/remi/php${php_ver}/* -name php.ini)
|
||||
fi
|
||||
|
||||
config_count=$(echo "$config_path" | wc -l)
|
||||
@@ -77,7 +106,7 @@ if [ "$config_count" -gt 1 ]; then
|
||||
multiphp_versions=$(ls -d /etc/opt/remi/php*/php-fpm.d 2> /dev/null | wc -l)
|
||||
fi
|
||||
if [ "$WEB_BACKEND" = 'php-fpm' ] || [ "$multiphp_versions" -gt 0 ]; then
|
||||
config_path=$(echo "$config_path" | grep fpm)
|
||||
config_path=$(echo "$config_path" | grep "php")
|
||||
else
|
||||
config_path=$(echo "$config_path" | grep httpd)
|
||||
fi
|
||||
@@ -89,7 +118,7 @@ keys="$keys |upload_max_filesize |post_max_size"
|
||||
keys="$keys |display_errors |error_reporting "
|
||||
|
||||
# Reading config
|
||||
config=$(cat $config_path | grep -v "^;")
|
||||
config=$(cat "$config_path" | grep -v "^;")
|
||||
|
||||
# Listing data
|
||||
case $format in
|
||||
|
||||
@@ -175,12 +175,12 @@ fi
|
||||
# Checking PHP intepreter
|
||||
if [ -n "$WEB_BACKEND" ] && [ "$WEB_BACKEND" != 'remote' ]; then
|
||||
if [ "$LOCAL_PHP" == "yes" ]; then
|
||||
php_versions=$(/opt/brepo/php*/sbin/php-fpm | cut -d'/' -f4 | sed 's|php||')
|
||||
php_versions=$(ls /opt/brepo/php*/sbin/php-fpm | cut -d'/' -f4 | sed 's|php||')
|
||||
for version in $php_versions; do
|
||||
proc_name="php-fpm"
|
||||
service_name="php${version}"
|
||||
service_name="fpm${version}"
|
||||
get_srv_state "$proc_name"
|
||||
data="$data\nNAME='$service_name-php-fpm' SYSTEM='php interpreter' STATE='$state'"
|
||||
data="$data\nNAME='brepo-php-$service_name' SYSTEM='php interpreter' STATE='$state'"
|
||||
data="$data CPU='$cpu' MEM='$mem' RTIME='$rtime'"
|
||||
done
|
||||
else
|
||||
|
||||
@@ -32,6 +32,10 @@ is_format_valid 'service' 'restart'
|
||||
# Action #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
if [ "$service" == "apache2" ]; then
|
||||
service="httpd"
|
||||
fi
|
||||
|
||||
log="/dev/null"
|
||||
if [ "$DEBUG_MODE" = "true" ]; then
|
||||
|
||||
@@ -49,13 +53,21 @@ if [ "$service" = "php-fpm" ]; then
|
||||
php_versions=$($BIN/v-list-sys-php plain)
|
||||
# Substitute php-fpm service name formats
|
||||
for version in $php_versions; do
|
||||
service_list="${service_list} php${version}-fpm"
|
||||
if [ "$LOCAL_PHP" == "yes" ]; then
|
||||
service_list="${service_list} brepo-php-fpm${version}"
|
||||
else
|
||||
service_list="${service_list} php${version}-php-fpm"
|
||||
fi
|
||||
done
|
||||
else
|
||||
service_list="$service"
|
||||
fi
|
||||
|
||||
for service in $service_list; do
|
||||
is_fpm="no"
|
||||
if [[ "$service" =~ ^php[0-9.]+-php-fpm ]] || [[ "$service" =~ brepo-php-fpm[0-9.]+ ]]; then
|
||||
is_fpm="yes"
|
||||
fi
|
||||
if [ "$service" = "iptables" ]; then
|
||||
# Run the restart rules for iptables firewall
|
||||
$BIN/v-stop-firewall
|
||||
@@ -64,21 +76,13 @@ for service in $service_list; do
|
||||
service $service upgrade >> $log 2>&1
|
||||
elif [ -z "$restart" -o "$restart" = "no" ] && [ \
|
||||
"$service" = "nginx" -o \
|
||||
"$service" = "apache2" -o \
|
||||
"$service" = "httpd" -o \
|
||||
"$service" = "exim4" -o \
|
||||
"$service" = "dovecot" -o \
|
||||
"$service" = "bind9" -o \
|
||||
"$service" = "named" -o \
|
||||
"$service" = "vsftpd" -o \
|
||||
"$service" = "php5.6-fpm" -o \
|
||||
"$service" = "php7.0-fpm" -o \
|
||||
"$service" = "php7.1-fpm" -o \
|
||||
"$service" = "php7.2-fpm" -o \
|
||||
"$service" = "php7.3-fpm" -o \
|
||||
"$service" = "php7.4-fpm" -o \
|
||||
"$service" = "php8.0-fpm" -o \
|
||||
"$service" = "php8.1-fpm" -o \
|
||||
"$service" = "php8.2-fpm" -o \
|
||||
"$is_fpm" = "yes" -o \
|
||||
"$service" = "proftpd" -o \
|
||||
"$service" = "ssh" -o \
|
||||
"$service" = "fail2ban" ]; then
|
||||
|
||||
27
func/main.sh
27
func/main.sh
@@ -1796,3 +1796,30 @@ get_conf_d_name(){
|
||||
echo "conf.d"
|
||||
fi
|
||||
}
|
||||
|
||||
# Get default php version
|
||||
# hestia.conf should be enabled before function
|
||||
get_system_default_php(){
|
||||
declare -a local_versions
|
||||
if [ "$LOCAL_PHP" == "yes" ]; then
|
||||
for version in /opt/brepo/php*/etc/php-fpm.d/www.conf; do
|
||||
local_ver=$(echo "$version" | awk -F"/" '{ print $4 }' | sed "s/php\([[:digit:]]\+\)/\1/g")
|
||||
if [ "$local_ver" != "php*" ]; then
|
||||
local_versions+=("$local_ver")
|
||||
fi
|
||||
done
|
||||
else
|
||||
for version in /etc/opt/remi/php*/php-fpm.d/www.conf; do
|
||||
local_ver=$(echo "$version" | awk -F"/" '{ print $5 }' | sed "s/php\([[:digit:]]\+\)/\1/g")
|
||||
if [ "$local_ver" != "php*" ]; then
|
||||
local_versions+=("$local_ver")
|
||||
fi
|
||||
done
|
||||
fi
|
||||
if [ ${#local_versions[@]} -eq 0 ]; then
|
||||
local_php_ver="82"
|
||||
else
|
||||
local_php_ver="${local_versions[0]}"
|
||||
fi
|
||||
echo "$local_php_ver"
|
||||
}
|
||||
@@ -1298,9 +1298,6 @@ rm -f $HESTIA/data/firewall/ipset/blacklist.sh $HESTIA/data/firewall/ipset/black
|
||||
# Installing apis
|
||||
cp -rf $HESTIA_COMMON_DIR/api $HESTIA/data/
|
||||
|
||||
# Set system php for selector
|
||||
hestiacp-php-admin system "$php_v"
|
||||
|
||||
# Configuring server hostname
|
||||
$HESTIA/bin/v-change-sys-hostname $servername > /dev/null 2>&1
|
||||
|
||||
@@ -1509,14 +1506,24 @@ fi
|
||||
#----------------------------------------------------------#
|
||||
|
||||
echo "[ * ] Configuring PHP..."
|
||||
# Set system php for selector
|
||||
hestiacp-php-admin system "$php_v"
|
||||
|
||||
ZONE=$(timedatectl > /dev/null 2>&1 | grep Timezone | awk '{print $2}')
|
||||
if [ -z "$ZONE" ]; then
|
||||
ZONE='UTC'
|
||||
fi
|
||||
for pconf in $(find /etc/opt/remi/php* -name php.ini); do
|
||||
sed -i "s%;date.timezone =%date.timezone = $ZONE%g" $pconf
|
||||
sed -i 's%_open_tag = Off%_open_tag = On%g' $pconf
|
||||
done
|
||||
if [ "$uselocalphp" == "yes" ]; then
|
||||
for pconf in $(find /opt/brepo/php* -name php.ini); do
|
||||
sed -i "s%;date.timezone =%date.timezone = $ZONE%g" $pconf
|
||||
sed -i 's%_open_tag = Off%_open_tag = On%g' $pconf
|
||||
done
|
||||
else
|
||||
for pconf in $(find /etc/opt/remi/php* -name php.ini); do
|
||||
sed -i "s%;date.timezone =%date.timezone = $ZONE%g" $pconf
|
||||
sed -i 's%_open_tag = Off%_open_tag = On%g' $pconf
|
||||
done
|
||||
fi
|
||||
|
||||
# Cleanup php session files not changed in the last 7 days (60*24*7 minutes)
|
||||
echo '#!/bin/sh' > /etc/cron.daily/php-session-cleanup
|
||||
|
||||
@@ -35,7 +35,7 @@ UPGRADE_RESTART_SERVICES='true'
|
||||
#######################################################################################
|
||||
|
||||
# Supported PHP versions
|
||||
multiphp_v=("5.6" "7.0" "7.1" "7.2" "7.3" "7.4" "8.0" "8.1" "8.2")
|
||||
multiphp_v=("5.6" "7.0" "7.1" "7.2" "7.3" "7.4" "8.0" "8.1" "8.2", "8.3")
|
||||
|
||||
#######################################################################################
|
||||
####### 3rd Party Software Updates #######
|
||||
|
||||
@@ -186,6 +186,7 @@ fi
|
||||
%changelog
|
||||
* Sun Jan 19 2025 Alexey Berezhok <a@bayrepo.ru> - 1.9.5-1
|
||||
- Added support alternative php
|
||||
- Fixed php.ini editing
|
||||
|
||||
* Sat Jan 11 2025 Alexey Berezhok <a@bayrepo.ru> - 1.9.4-1
|
||||
- Added quota support in rpm for xfs and ext4
|
||||
|
||||
@@ -29,32 +29,18 @@ exec(HESTIA_CMD . "v-list-web-templates-backend json", $output, $return_var);
|
||||
$backend_templates = json_decode(implode("", $output), true);
|
||||
unset($output);
|
||||
|
||||
exec(HESTIA_CMD . "v-check-rhel-utility", $output, $return_var);
|
||||
$is_rhel = str_contains(implode("", $output), "+");
|
||||
unset($output);
|
||||
//exec(HESTIA_CMD . "v-check-rhel-utility", $output, $return_var);
|
||||
//$is_rhel = str_contains(implode("", $output), "+");
|
||||
//unset($output);
|
||||
|
||||
$v_php_versions = [
|
||||
"php-5.6",
|
||||
"php-7.0",
|
||||
"php-7.1",
|
||||
"php-7.2",
|
||||
"php-7.3",
|
||||
"php-7.4",
|
||||
"php-8.0",
|
||||
"php-8.1",
|
||||
"php-8.2",
|
||||
"php-74",
|
||||
"php-80",
|
||||
"php-81",
|
||||
"php-82",
|
||||
"php-83",
|
||||
];
|
||||
|
||||
if ($is_rhel){
|
||||
$v_php_versions = [
|
||||
"php-74",
|
||||
"php-80",
|
||||
"php-81",
|
||||
"php-82",
|
||||
"php-83",
|
||||
"php-84",
|
||||
];
|
||||
}
|
||||
|
||||
sort($v_php_versions);
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ if (!empty($_POST["save"])) {
|
||||
}
|
||||
|
||||
// List config
|
||||
exec(HESTIA_CMD . "v-list-sys-php-config json", $output, $return_var);
|
||||
exec(HESTIA_CMD . "v-list-sys-php-config default json", $output, $return_var);
|
||||
$data = json_decode(implode("", $output), true);
|
||||
unset($output);
|
||||
$v_memory_limit = $data["CONFIG"]["memory_limit"];
|
||||
|
||||
@@ -11,11 +11,32 @@ if ($_SESSION["userContext"] != "admin") {
|
||||
exit();
|
||||
}
|
||||
|
||||
$php_version = "default";
|
||||
if (!empty($_GET["vers"])){
|
||||
$php_version_tmp = trim(urldecode($_GET["vers"]));
|
||||
if (preg_match('/^\d+$/', $php_version_tmp) === 1){
|
||||
exec(HESTIA_CMD . "v-list-sys-php json", $output, $return_var);
|
||||
$php = json_decode(implode("", $output), true);
|
||||
unset($output);
|
||||
foreach ($php as $version) {
|
||||
if ($version == $php_version_tmp){
|
||||
$php_version = $php_version_tmp;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check POST request
|
||||
if (!empty($_POST["save"])) {
|
||||
// Check token
|
||||
verify_csrf($_POST);
|
||||
|
||||
$php_save = "php";
|
||||
if ($php_version != "default"){
|
||||
$php_save .= $php_version;
|
||||
}
|
||||
|
||||
// Set restart flag
|
||||
$v_restart = "yes";
|
||||
if (empty($_POST["v_restart"])) {
|
||||
@@ -30,7 +51,7 @@ if (!empty($_POST["save"])) {
|
||||
fwrite($fp, str_replace("\r\n", "\n", $_POST["v_config"]));
|
||||
fclose($fp);
|
||||
exec(
|
||||
HESTIA_CMD . "v-change-sys-service-config " . $new_conf . " php " . $v_restart,
|
||||
HESTIA_CMD . "v-change-sys-service-config " . $new_conf . " " . $php_save . " " . $v_restart,
|
||||
$output,
|
||||
$return_var,
|
||||
);
|
||||
@@ -46,7 +67,7 @@ if (!empty($_POST["save"])) {
|
||||
}
|
||||
|
||||
// List config
|
||||
exec(HESTIA_CMD . "v-list-sys-php-config json", $output, $return_var);
|
||||
exec(HESTIA_CMD . "v-list-sys-php-config " . $php_version . " json", $output, $return_var);
|
||||
$data = json_decode(implode("", $output), true);
|
||||
unset($output);
|
||||
$v_memory_limit = $data["CONFIG"]["memory_limit"];
|
||||
|
||||
@@ -36,7 +36,7 @@ if (!empty($_POST["save"])) {
|
||||
);
|
||||
check_return_code($return_var, $output);
|
||||
unset($output);
|
||||
unlink($new_conf);
|
||||
//unlink($new_conf);
|
||||
}
|
||||
|
||||
// Set success message
|
||||
@@ -46,7 +46,7 @@ if (!empty($_POST["save"])) {
|
||||
}
|
||||
|
||||
// List config
|
||||
exec(HESTIA_CMD . "v-list-sys-php-config json", $output, $return_var);
|
||||
exec(HESTIA_CMD . "v-list-sys-php-config default json", $output, $return_var);
|
||||
$data = json_decode(implode("", $output), true);
|
||||
unset($output);
|
||||
$v_memory_limit = $data["CONFIG"]["memory_limit"];
|
||||
|
||||
@@ -126,6 +126,7 @@ $phpfpm = [];
|
||||
foreach ($php as $version) {
|
||||
$phpfpm[] = "php" . $version . "-fpm";
|
||||
$phpfpm[] = "php" . $version . "-php-fpm";
|
||||
$phpfpm[] = "brepo-php-fpm" . $version;
|
||||
}
|
||||
$clamav_names = [];
|
||||
$clamav_names[] = "clamav-daemon";
|
||||
|
||||
@@ -126,15 +126,16 @@
|
||||
$spnd_icon_class = 'icon-green';
|
||||
$state_icon = 'fa-circle-minus icon-red';
|
||||
}
|
||||
$vers="";
|
||||
if (in_array($key, $phpfpm)){
|
||||
$edit_url="php";
|
||||
preg_match('/\d+/', $key, $matches);
|
||||
$vers=$matches[0] ?? '82';;
|
||||
} else {
|
||||
$edit_url=$key;
|
||||
}
|
||||
if (in_array($key, $clamav_names)){
|
||||
$edit_url="clamav-daemon";
|
||||
} else {
|
||||
$edit_url=$key;
|
||||
}
|
||||
|
||||
$cpu = $data[$key]['CPU'] / 10;
|
||||
@@ -155,7 +156,11 @@
|
||||
<div class="units-table-cell units-table-heading-cell u-text-bold">
|
||||
<span class="u-hide-desktop"><?= _("Service") ?>:</span>
|
||||
<i class="fas <?= $state_icon ?> u-mr5"></i>
|
||||
<a href="/edit/server/<? echo $edit_url ?>/" title="<?= _("Edit") ?>: <?= $key ?>">
|
||||
<a href="/edit/server/<? echo $edit_url ?>/<?php
|
||||
if ($vers!=""){
|
||||
echo "?vers=" . urlencode($vers);
|
||||
}
|
||||
?>" title="<?= _("Edit") ?>: <?= $key ?>">
|
||||
<?= $key ?>
|
||||
</a>
|
||||
</div>
|
||||
@@ -164,7 +169,11 @@
|
||||
<li class="units-table-row-action shortcut-enter" data-key-action="href">
|
||||
<a
|
||||
class="units-table-row-action-link"
|
||||
href="/edit/server/<? echo $edit_url ?>/"
|
||||
href="/edit/server/<? echo $edit_url ?>/<?php
|
||||
if ($vers!=""){
|
||||
echo "?vers=". urlencode($vers);
|
||||
}
|
||||
?>"
|
||||
title="<?= _("Edit") ?>"
|
||||
>
|
||||
<i class="fas fa-pencil icon-orange"></i>
|
||||
|
||||
Reference in New Issue
Block a user