Use local php. Part 1

devel
Alexey Berezhok 3 months ago
parent 8e2a9e1f42
commit 66e574dd33

@ -2,7 +2,12 @@
All notable changes to this project will be documented in this file.
## [1.9.2.rpm] - Alpha release
## [1.9.4.rpm] - Release
- Fixed sha-512 auth in hestiacp
- Added quota support for rpm based os
## [1.9.2.rpm] - Release
- Forked from 1.8.6 alpha and reworked for rpm based systems support
- Added passenger support (https://hestiadocs.brepo.ru/docs/extensions/extended-modules.html#passenger-manager)

@ -113,12 +113,7 @@ if ! echo "$DB_SYSTEM" | grep -w 'pgsql' > /dev/null; then
fi
# Install php packages
if [ -f '/etc/redhat-release' ]; then
dnf install -q -y $mph > /dev/null 2>&1 &
else
apt-get -qq update
apt-get -y -qq -o Dpkg::Options::="--force-confold" install $mph > /dev/null 2>&1 &
fi
dnf install -q -y $mph > /dev/null 2>&1 &
BACK_PID=$!
# Check if package installation is done, print a spinner
@ -136,20 +131,15 @@ echo
# Check if installation was successful
if [ ! -f "$php_fpm" ]; then
echo "ERROR: Installation failed, please run the following command manually for debugging:"
if [ -f '/etc/redhat-release' ]; then
echo "dnf install $mph"
else
echo "apt-get install $mph"
fi
echo "dnf install $mph"
fi
if [ -f '/etc/redhat-release' ]; then
result_alt_php=$(alternatives --display php | grep /usr/bin/php$version)
if [ -z "$result_alt_php" ]; then
alternatives --install /usr/bin/php php /usr/bin/php$version 1 > /dev/null 2>&1
fi
result_alt_php=$(alternatives --display php | grep /usr/bin/php$version)
if [ -z "$result_alt_php" ]; then
alternatives --install /usr/bin/php php /usr/bin/php$version 1 > /dev/null 2>&1
fi
# Check if required modules for apache2 are enabled
if [ "$WEB_SYSTEM" = "apache2" ]; then
if [ -f /etc/redhat-release ]; then

@ -1449,6 +1449,56 @@ check_backup_conditions() {
done
}
fn_get_link_name(){
str_result=""
ext_name=$1
pattern=("01-ioncube.ini" "10-opcache.ini" "20-bcmath.ini" "20-bz2.ini" "20-calendar.ini" "20-ctype.ini" "20-curl.ini" "20-dba.ini" "20-dom.ini" "20-enchant.ini" "20-exif.ini" "20-ffi.ini" "20-fileinfo.ini" "20-ftp.ini" "20-gd.ini" "20-gettext.ini" "20-gmp.ini" "20-iconv.ini" "20-imap.ini" "20-intl.ini" "20-ldap.ini" "20-mbstring.ini" "20-mysqlnd.ini" "20-odbc.ini" "20-pdo.ini" "20-phar.ini" "20-posix.ini" "20-pspell.ini" "20-shmop.ini" "20-simplexml.ini" "20-sockets.ini" "20-sqlite3.ini" "20-sysvmsg.ini" "20-sysvsem.ini" "20-sysvshm.ini" "20-tokenizer.ini" "20-xml.ini" "20-xmlwriter.ini" "20-xsl.ini" "30-mysqli.ini" "30-pdo_dblib.ini" "30-pdo_firebird.ini" "30-pdo_mysql.ini" "30-pdo_odbc.ini" "30-pdo_sqlite.ini" "30-xmlreader.ini" "30-zip.ini" "40-apcu.ini" "40-ast.ini" "40-bolt.ini" "40-brotli.ini" "40-geos.ini" "40-imagick.ini" "40-libvirt-php.ini" "40-lz4.ini" "40-pdlib.ini")
check="^[0-9]+-${ext_name}.ini"
for str in ${pattern[@]}; do
if [[ $str =~ $check ]]; then
str_result="$str"
break
fi
done
if [ -z "$str_result" ]; then
echo "50-${ext_name}.ini"
else
echo "$str_result"
fi
}
fn_enable_local_php_extension(){
vers=$1
ext_name=$2
ext_nm=$(fn_get_link_name "$ext_name")
if [ -e "/opt/brepo/php${vers}/etc/php.d/" ]; then
if [ ! -e "/opt/brepo/php${vers}/etc/php.d/${ext_nm}" -a -e "/opt/brepo/php${vers}/etc/mod-installed/${ext_name}.ini" ]; then
pushd "/opt/brepo/php${vers}/etc/php.d/"
ln -s ../mod-installed/${ext_name}.ini /opt/brepo/php${vers}/etc/php.d/${ext_nm}
popd
fi
fi
}
fn_disable_local_php_extension(){
vers=$1
ext_name=$2
ext_nm=$(fn_get_link_name "$ext_name")
if [ -e "/opt/brepo/php${vers}/etc/php.d/" ]; then
if [ -e "/opt/brepo/php${vers}/etc/php.d/${ext_nm}" ]; then
rm -f "/opt/brepo/php${vers}/etc/php.d/${ext_nm}"
fi
fi
}
fn_enable_mod_php(){
vers=$1
if [ -e "/etc/httpd/conf.d.prep/php${vers}.conf" ]; then
ln -s /etc/httpd/conf.d.prep/php${vers}.conf /etc/httpd/conf.h.d/mod_php${vers}.conf
fi
}
# Define download function
download_file() {
local url=$1

@ -38,25 +38,21 @@ HESTIA_COMMON_DIR="$HESTIA/install/common"
VERBOSE='no'
# Define software versions
HESTIA_INSTALL_VER='1.9.0~alpha'
HESTIA_INSTALL_VER='1.9.4.rpm~alpha'
# Dependencies
mariadb_v="10.11"
if [ "$release" -lt 9 ]; then
multiphp_v=("72" "73" "74" "80" "81" "82" "83")
else
multiphp_v=("74" "80" "81" "82" "83")
fi
# default PHP version
php_v="82"
php_modules_install="mysqlnd mysqli pdo_mysql pgsql pdo sqlite pdo_sqlite pdo_pgsql imap ldap zip opcache xmlwriter xmlreader gd intl pspell"
php_modules_disable=""
mod_php="enable"
software="nginx
httpd.${arch} httpd-tools httpd-itk mod_fcgid mod_suphp mod_ssl
php${php_v}-php.${arch} php${php_v}-php-cgi.${arch} php${php_v}-php-mysqlnd.${arch} php${php_v}-php-pgsql.${arch}
php${php_v}-php-pdo php${php_v}-php-common php${php_v}-php-pecl-imagick php${php_v}-php-imap php${php_v}-php-ldap
php${php_v}-php-pecl-apcu php${php_v}-php-pecl-zip php${php_v}-php-cli php${php_v}-php-opcache php${php_v}-php-xml
php${php_v}-php-gd php${php_v}-php-intl php${php_v}-php-mbstring php${php_v}-php-pspell php${php_v}-php-readline
MariaDB-client MariaDB-common MariaDB-server
mysql.${arch} mysql-common mysql-server
postgresql-server postgresql sqlite.${arch}
@ -95,6 +91,7 @@ help() {
-l, --lang Default language default: en
-y, --interactive Interactive install [yes|no] default: yes
-I, --nopublicip Use local ip [yes|no] default: yes
-u, --uselocalphp Use PHP from local repo [yes|no] default: yes
-s, --hostname Set hostname
-e, --email Set admin email
-p, --password Set admin password
@ -206,6 +203,56 @@ validate_email() {
fi
}
get_link_name(){
str_result=""
ext_name=$1
pattern=("01-ioncube.ini" "10-opcache.ini" "20-bcmath.ini" "20-bz2.ini" "20-calendar.ini" "20-ctype.ini" "20-curl.ini" "20-dba.ini" "20-dom.ini" "20-enchant.ini" "20-exif.ini" "20-ffi.ini" "20-fileinfo.ini" "20-ftp.ini" "20-gd.ini" "20-gettext.ini" "20-gmp.ini" "20-iconv.ini" "20-imap.ini" "20-intl.ini" "20-ldap.ini" "20-mbstring.ini" "20-mysqlnd.ini" "20-odbc.ini" "20-pdo.ini" "20-phar.ini" "20-posix.ini" "20-pspell.ini" "20-shmop.ini" "20-simplexml.ini" "20-sockets.ini" "20-sqlite3.ini" "20-sysvmsg.ini" "20-sysvsem.ini" "20-sysvshm.ini" "20-tokenizer.ini" "20-xml.ini" "20-xmlwriter.ini" "20-xsl.ini" "30-mysqli.ini" "30-pdo_dblib.ini" "30-pdo_firebird.ini" "30-pdo_mysql.ini" "30-pdo_odbc.ini" "30-pdo_sqlite.ini" "30-xmlreader.ini" "30-zip.ini" "40-apcu.ini" "40-ast.ini" "40-bolt.ini" "40-brotli.ini" "40-geos.ini" "40-imagick.ini" "40-libvirt-php.ini" "40-lz4.ini" "40-pdlib.ini")
check="^[0-9]+-${ext_name}.ini"
for str in ${pattern[@]}; do
if [[ $str =~ $check ]]; then
str_result="$str"
break
fi
done
if [ -z "$str_result" ]; then
echo "50-${ext_name}.ini"
else
echo "$str_result"
fi
}
enable_local_php_extension(){
vers=$1
ext_name=$2
ext_nm=$(get_link_name "$ext_name")
if [ -e "/opt/brepo/php${vers}/etc/php.d/" ]; then
if [ ! -e "/opt/brepo/php${vers}/etc/php.d/${ext_nm}" -a -e "/opt/brepo/php${vers}/etc/mod-installed/${ext_name}.ini" ]; then
pushd "/opt/brepo/php${vers}/etc/php.d/"
ln -s ../mod-installed/${ext_name}.ini /opt/brepo/php${vers}/etc/php.d/${ext_nm}
popd
fi
fi
}
disable_local_php_extension(){
vers=$1
ext_name=$2
ext_nm=$(get_link_name "$ext_name")
if [ -e "/opt/brepo/php${vers}/etc/php.d/" ]; then
if [ -e "/opt/brepo/php${vers}/etc/php.d/${ext_nm}" ]; then
rm -f "/opt/brepo/php${vers}/etc/php.d/${ext_nm}"
fi
fi
}
enable_mod_php(){
vers=$1
if [ -e "/etc/httpd/conf.d.prep/php${vers}.conf" ]; then
ln -s /etc/httpd/conf.d.prep/php${vers}.conf /etc/httpd/conf.h.d/mod_php${vers}.conf
fi
}
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
@ -245,6 +292,7 @@ for arg; do
--with-debs) args="${args}-D " ;;
--help) args="${args}-h " ;;
--nopublicip) args="${args}-I " ;;
--uselocalphp) args="${args}-u" ;;
*)
[[ "${arg:0:1}" == "-" ]] || delim="\""
args="${args}${delim}${arg}${delim} "
@ -254,7 +302,7 @@ done
eval set -- "$args"
# Parsing arguments
while getopts "I:a:w:v:j:k:m:M:g:d:x:z:Z:c:t:i:b:r:o:q:l:y:s:e:p:R:fh" Option; do
while getopts "u:I:a:w:v:j:k:m:M:g:d:x:z:Z:c:t:i:b:r:o:q:l:y:s:e:p:R:fh" Option; do
case $Option in
a) apache=$OPTARG ;; # Apache
w) phpfpm=$OPTARG ;; # PHP-FPM
@ -284,6 +332,7 @@ while getopts "I:a:w:v:j:k:m:M:g:d:x:z:Z:c:t:i:b:r:o:q:l:y:s:e:p:R:fh" Option; d
f) force='yes' ;; # Force install
h) help ;; # Help
I) nopublicip=$OPTARG ;; # NoPublicIP
u) uselocalphp=$OPTARG ;; # UseLocalPHP
*) help ;; # Print help (default)
esac
done
@ -320,6 +369,7 @@ set_default_value 'api' 'yes'
set_default_value 'nopublicip' 'yes'
set_default_port '8083'
set_default_lang 'en'
set_default_value 'uselocalphp' 'yes'
# Checking software conflicts
if [ "$proftpd" = 'yes' ]; then
@ -460,23 +510,23 @@ esac
install_welcome_message() {
DISPLAY_VER=$(echo $HESTIA_INSTALL_VER | sed "s|~alpha||g" | sed "s|~beta||g")
echo
echo ' _ _ _ _ ____ ____ '
echo ' | | | | ___ ___| |_(_) __ _ / ___| _ \ '
echo ' | |_| |/ _ \/ __| __| |/ _` | | | |_) | '
echo ' | _ | __/\__ \ |_| | (_| | |___| __/ '
echo ' |_| |_|\___||___/\__|_|\__,_|\____|_| '
echo ' _ _ _ _ ____ ____ '
echo ' | | | | ___ ___| |_(_) __ _ / ___| _ \ _ _ . . '
echo ' | |_| |/ _ \/ __| __| |/ _` | | | |_) | | \| \|\/| '
echo ' | _ | __/\__ \ |_| | (_| | |___| __/ |_/|_/| | '
echo ' |_| |_|\___||___/\__|_|\__,_|\____|_| | \| | | '
echo " "
echo " Hestia Control Panel "
echo " Hestia Control Panel(rpm edition) "
if [[ "$HESTIA_INSTALL_VER" =~ "beta" ]]; then
echo " BETA RELEASE "
fi
if [[ "$HESTIA_INSTALL_VER" =~ "alpha" ]]; then
echo " DEVELOPMENT SNAPSHOT "
echo " NOT INTENDED FOR PRODUCTION USE "
echo " USE AT YOUR OWN RISK "
fi
echo " ${DISPLAY_VER} "
echo " www.hestiacp.com "
echo " hestiadocs.brepo.ru "
echo " Original: www.hestiacp.com "
echo
echo "========================================================================"
echo
@ -682,7 +732,19 @@ echo "[ * ] NGINX"
# Installing Remi PHP repo
echo "[ * ] PHP"
dnf install -y https://rpms.remirepo.net/enterprise/remi-release-$release.rpm
php_pkgs_lst=""
if [ "$uselocalphp" == "yes" ]; then
write_config_value "LOCAL_PHP" "yes"
php_pkgs_lst="brepo-php${php_v} brepo-php${php_v}-mod-apache"
else
write_config_value "LOCAL_PHP" "no"
php_pkgs_lst="php${php_v}-php.${arch} php${php_v}-php-cgi.${arch} php${php_v}-php-mysqlnd.${arch} php${php_v}-php-pgsql.${arch}
php${php_v}-php-pdo php${php_v}-php-common php${php_v}-php-pecl-imagick php${php_v}-php-imap php${php_v}-php-ldap
php${php_v}-php-pecl-apcu php${php_v}-php-pecl-zip php${php_v}-php-cli php${php_v}-php-opcache php${php_v}-php-xml
php${php_v}-php-gd php${php_v}-php-intl php${php_v}-php-mbstring php${php_v}-php-pspell php${php_v}-php-readline"
dnf install -y https://rpms.remirepo.net/enterprise/remi-release-$release.rpm
fi
software="$software $php_pkgs_lst"
# Installing MariaDB repo
if [ "$mysql" = 'yes' ]; then
@ -803,10 +865,14 @@ rm -rf $HESTIA > /dev/null 2>&1
#----------------------------------------------------------#
if [ "$phpfpm" = 'yes' ]; then
fpm="php${php_v}-php-fpm php${php_v}-php-cgi.${arch} php${php_v}-php-mysqlnd.${arch} php${php_v}-php-pgsql.${arch}
php${php_v}-php-pdo php${php_v}-php-common php${php_v}-php-pecl-imagick php${php_v}-php-imap php${php_v}-php-ldap
php${php_v}-php-pecl-apcu php${php_v}-php-pecl-zip php${php_v}-php-cli php${php_v}-php-opcache php${php_v}-php-xml
php${php_v}-php-gd php${php_v}-php-intl php${php_v}-php-mbstring php${php_v}-php-pspell php${php_v}-php-readline"
if [ "$uselocalphp" == "yes" ]; then
fpm="brepo-php${php_v}-fpm"
else
fpm="php${php_v}-php-fpm php${php_v}-php-cgi.${arch} php${php_v}-php-mysqlnd.${arch} php${php_v}-php-pgsql.${arch}
php${php_v}-php-pdo php${php_v}-php-common php${php_v}-php-pecl-imagick php${php_v}-php-imap php${php_v}-php-ldap
php${php_v}-php-pecl-apcu php${php_v}-php-pecl-zip php${php_v}-php-cli php${php_v}-php-opcache php${php_v}-php-xml
php${php_v}-php-gd php${php_v}-php-intl php${php_v}-php-mbstring php${php_v}-php-pspell php${php_v}-php-readline"
fi
software="$software $fpm"
fi
@ -823,6 +889,8 @@ if [ "$apache" = 'no' ]; then
software=$(echo "$software" | sed -e "s/mod_fcgid//")
software=$(echo "$software" | sed -e "s/mod_ssl//")
software=$(echo "$software" | sed -e "s/php${php_v}-php.${arch}//")
software=$(echo "$software" | sed -e "s/brepo-php${php_v}-mod-apache//")
mod_php="disable"
fi
if [ "$vsftpd" = 'no' ]; then
software=$(echo "$software" | sed -e "s/vsftpd//")
@ -871,6 +939,9 @@ if [ "$postgresql" = 'no' ]; then
software=$(echo "$software" | sed -e "s/postgresql-server//")
software=$(echo "$software" | sed -e "s/php${php_v}-php-pgsql.${arch}//")
software=$(echo "$software" | sed -e "s/phppgadmin//")
php_modules_install=$(echo "$php_modules_install" | sed -e "s/pgsql//")
php_modules_install=$(echo "$php_modules_install" | sed -e "s/pdo_pgsql//")
php_modules_disable="$php_modules_disable pgsql pdo_pgsql"
fi
if [ "$fail2ban" = 'no' ]; then
software=$(echo "$software" | sed -e "s/fail2ban//")
@ -886,6 +957,8 @@ if [ "$phpfpm" = 'yes' ]; then
software=$(echo "$software" | sed -e "s/mod_suphp//")
software=$(echo "$software" | sed -e "s/mod_fcgid//")
software=$(echo "$software" | sed -e "s/php${php_v}-php.${arch}//")
software=$(echo "$software" | sed -e "s/brepo-php${php_v}-mod-apache//")
mod_php="disable"
fi
if [ -d "$withrpms" ]; then
software=$(echo "$software" | sed -e "s/hestia-nginx//")
@ -933,7 +1006,21 @@ echo "========================================================================"
echo
# Create PHP symlink
alternatives --install /usr/bin/php php /opt/remi/php${php_v}/root/usr/bin/php 1
if [ "$uselocalphp" == "yes" ]; then
alternatives --install /usr/bin/php php /opt/brepo/php${php_v}/bin/php 1
echo "[ * ] Configuring php settings..."
for mod in $php_modules_install; do
enable_local_php_extension "${php_v}" "$mod"
done
for mod in $php_modules_disable; do
disable_local_php_extension "${php_v}" "$mod"
done
if [ "$mod_php" == "enable" ]; then
enable_mod_php "${php_v}"
fi
else
alternatives --install /usr/bin/php php /opt/remi/php${php_v}/root/usr/bin/php 1
fi
# Install Hestia packages from local folder
if [ -n "$withrpms" ] && [ -d "$withrpms" ]; then
@ -1330,7 +1417,7 @@ if [ "$apache" = 'yes' ]; then
# Enable needed modules
if [ "$nginx" = "no" ]; then
dnf install -y mod_ssl mod_h2
dnf install -y mod_ssl mod_http2
fi
# IDK why those modules still here, but ok. if they are disabled by default

@ -1,7 +1,7 @@
{
"name": "hestia",
"private": true,
"version": "1.9.2.rpm",
"version": "1.9.4.rpm",
"description": "An open-source Linux web server control panel.",
"repository": "https://github.com/hestiacp/hestiacp",
"license": "GPL-3.0-or-later",

@ -2,7 +2,7 @@
%global _hardened_build 1
Name: hestia
Version: 1.9.3
Version: 1.9.4
Release: 1%{dist}
Summary: Hestia Control Panel
Group: System Environment/Base
@ -184,6 +184,9 @@ fi
%{_tmpfilesdir}/%{name}.conf
%changelog
* Sat Jan 11 2025 Alexey Berezhok <a@bayrepo.ru> - 1.9.4-1
- Added quota support in rpm for xfs and ext4
* Sun Jan 05 2025 Alexey Berezhok <a@bayrepo.ru> - 1.9.3-1
- Added minor fixes
- Added authorization fix for rhel 9.5

Loading…
Cancel
Save