Просмотр исходного кода

Merge pull request #546 from Lupul/dev-0714

Multiphp improvements
Zollner Robert 6 лет назад
Родитель
Сommit
d183e00813
57 измененных файлов с 576 добавлено и 275 удалено
  1. 1 1
      bin/v-add-fs-archive
  2. 1 1
      bin/v-add-fs-directory
  3. 1 1
      bin/v-add-fs-file
  4. 3 2
      bin/v-add-sys-ip
  5. 1 1
      bin/v-add-sys-quota
  6. 3 1
      bin/v-add-user
  7. 2 1
      bin/v-add-web-domain-backend
  8. 20 22
      bin/v-add-web-php
  9. 1 1
      bin/v-backup-users
  10. 1 1
      bin/v-change-database-owner
  11. 1 1
      bin/v-change-fs-file-permission
  12. 5 5
      bin/v-change-sys-ip-nat
  13. 3 3
      bin/v-change-sys-ip-owner
  14. 1 1
      bin/v-change-sys-language
  15. 3 3
      bin/v-change-sys-webmail
  16. 2 1
      bin/v-change-web-domain-backend-tpl
  17. 1 1
      bin/v-check-fs-permission
  18. 1 1
      bin/v-copy-fs-directory
  19. 1 1
      bin/v-delete-fs-directory
  20. 1 1
      bin/v-delete-fs-file
  21. 5 3
      bin/v-delete-sys-ip
  22. 4 6
      bin/v-delete-web-php
  23. 1 1
      bin/v-extract-fs-archive
  24. 2 2
      bin/v-generate-api-key
  25. 1 1
      bin/v-get-fs-file-type
  26. 1 1
      bin/v-list-fs-directory
  27. 1 1
      bin/v-list-users-stats
  28. 1 1
      bin/v-move-fs-directory
  29. 1 1
      bin/v-move-fs-file
  30. 1 1
      bin/v-open-fs-config
  31. 1 1
      bin/v-open-fs-file
  32. 1 1
      bin/v-rebuild-users
  33. 1 1
      bin/v-search-fs-object
  34. 2 2
      bin/v-search-object
  35. 1 1
      bin/v-update-letsencrypt-ssl
  36. 1 1
      bin/v-update-mail-templates
  37. 2 2
      bin/v-update-sys-ip
  38. 2 2
      bin/v-update-user-counters
  39. 1 1
      bin/v-update-user-package
  40. 1 1
      bin/v-update-user-stats
  41. 7 2
      bin/v-update-web-templates
  42. 17 13
      func/domain.sh
  43. 5 0
      func/main.sh
  44. 1 1
      func/upgrade.sh
  45. 31 0
      install/deb/php-fpm/multiphp.tpl
  46. 44 0
      install/deb/templates/web/apache2/php-fpm/default.stpl
  47. 41 0
      install/deb/templates/web/apache2/php-fpm/default.tpl
  48. 5 2
      install/deb/templates/web/php-fpm/default.tpl
  49. 26 91
      install/hst-install-debian.sh
  50. 21 81
      install/hst-install-ubuntu.sh
  51. 127 0
      install/upgrade/manual/migrate-190718-multiphp.sh
  52. 6 1
      install/upgrade/versions/latest.sh
  53. 2 2
      src/deb/nginx/nginx.conf
  54. 59 1
      web/css/styles.min.css
  55. 72 0
      web/edit/server/index.php
  56. 4 0
      web/inc/i18n/en.php
  57. 24 0
      web/templates/admin/edit_server.html

+ 1 - 1
bin/v-add-fs-archive

@@ -15,7 +15,7 @@ if [ -z "$src0" ]; then
 fi
 
 # Checking hestia user
-if [ ! -e "$HESTIA/data/users/$user" ]; then
+if [ ! -d "$HESTIA/data/users/$user" ]; then
     echo "Error: hestia user $user doesn't exist"
     exit 3
 fi

+ 1 - 1
bin/v-add-fs-directory

@@ -14,7 +14,7 @@ if [ -z "$dst_dir" ]; then
 fi
 
 # Checking hestia user
-if [ ! -e "$HESTIA/data/users/$user" ]; then
+if [ ! -d "$HESTIA/data/users/$user" ]; then
     echo "Error: hestia user $user doesn't exist"
     exit 3
 fi

+ 1 - 1
bin/v-add-fs-file

@@ -14,7 +14,7 @@ if [ -z "$dst_file" ]; then
 fi
 
 # Checking hestia user
-if [ ! -e "$HESTIA/data/users/$user" ]; then
+if [ ! -d "$HESTIA/data/users/$user" ]; then
     echo "Error: hestia user $user doesn't exist"
     exit 3
 fi

+ 3 - 2
bin/v-add-sys-ip

@@ -81,6 +81,7 @@ if [ -z "$sys_ip_check" ]; then
         fi
         IFS='%'
         echo -e $sys_ip >> /etc/netplan/60-hestia.yaml
+        unset IFS
     else
         sys_ip="\n# Added by hestia"
         sys_ip="$sys_ip\nauto $iface"
@@ -178,8 +179,8 @@ fi
 increase_user_value "$user" '$IP_OWNED'
 if [ "$user" = 'admin' ]; then
     if [ "$ip_status" = 'shared' ]; then
-        for user in $(ls $HESTIA/data/users); do
-            increase_user_value "$user" '$IP_AVAIL'
+        for hestia_user in $($HESTIA/bin/v-list-sys-users plain); do
+            increase_user_value "$hestia_user" '$IP_AVAIL'
         done
     else
         increase_user_value 'admin' '$IP_AVAIL'

+ 1 - 1
bin/v-add-sys-quota

@@ -75,7 +75,7 @@ else
 fi
 
 # Rebuilding user quota
-for user in $(ls $HESTIA/data/users); do
+for user in $($HESTIA/bin/v-list-sys-users plain); do
     $BIN/v-update-user-quota $user
 done
 

+ 3 - 1
bin/v-add-user

@@ -68,7 +68,9 @@ if [ -z "$(grep ^hestia-users: /etc/group)" ]; then
 fi
 
 # Add membership to hestia-users group to non-admin users
-if [ "$user" != "admin" ]; then
+if [ "$user" = "admin" ]; then
+    setfacl -m "g:admin:r-x" "$HOMEDIR/$user"
+else
     usermod -a -G "hestia-users" "$user"
     setfacl -m "u:$user:r-x" "$HOMEDIR/$user"
 fi

+ 2 - 1
bin/v-add-web-domain-backend

@@ -62,7 +62,8 @@ cat $WEBTPL/$WEB_BACKEND/$template.tpl |\
     sed -e "s|%backend_port%|$backend_port|" \
         -e "s|%user%|$user|g"\
         -e "s|%domain%|$domain|g"\
-        -e "s|%backend%|$backend_type|g" > $pool/$backend_type.conf
+        -e "s|%backend%|$backend_type|g"\
+        -e "s|%backend_version%|$backend_version|g" > $pool/$backend_type.conf
 
 
 #----------------------------------------------------------#

+ 20 - 22
bin/v-add-web-php

@@ -33,7 +33,7 @@ if [[ ! $version =~ ^[0-9]\.[0-9]+ ]]; then
 fi
 
 # Check if php version already exists
-if [ -f "$php_fpm" ] && [ -f "$HESTIA/data/templates/$WEB_SYSTEM/PHP-$version.sh" ]; then
+if [ -f "$php_fpm" ] && [ -f "$HESTIA/data/templates/web/php-fpm/PHP-${version/\./_}.tpl" ]; then
     echo "Version already installed..."
     exit
 fi
@@ -51,13 +51,21 @@ fi
 mph="php$version-mbstring php$version-bcmath php$version-cli php$version-curl
      php$version-fpm php$version-gd php$version-intl php$version-mysql
      php$version-soap php$version-xml php$version-zip php$version-mbstring
-     php$version-json php$version-bz2 php$version-pspell"
+     php$version-json php$version-bz2 php$version-pspell php$version-imagick php$version-pgsql"
 
 # Check is version is 7.1 or below to add mcrypt
 if [[ `echo "$version 7.2" | awk '{print ($1 < $2)}'` == 1 ]]; then
     mph="$mph php$version-mcrypt"
 fi
 
+if [ -z "$DB_SYSTEM" -o "$DB_SYSTEM" = "mysql" ]; then
+    mph=$(echo "$mph" | sed -e "s/php$version-pgsql//")
+fi
+
+if [ -z "$DB_SYSTEM" -o "$DB_SYSTEM" = "pgsql" ]; then
+    mph=$(echo "$mph" | sed -e "s/php$version-mysql//")
+fi
+
 # Install php packages
 apt-get -qq update
 apt-get -y install $mph > /dev/null 2>&1 &
@@ -83,42 +91,32 @@ fi
 
 # Check if required modules for apache2 are enabled
 if [ "$WEB_SYSTEM" = "apache2" ]; then
-    if ! ls -l /etc/apache2/mods-enabled/ | grep --quiet "proxy_fcgi"; then
-        a2enmod proxy_fcgi > /dev/null 2>&1
-        restart_apache2="yes"
-    fi
-    if ! ls -l /etc/apache2/mods-enabled/ | grep --quiet "setenvif"; then
-        a2enmod setenvif > /dev/null 2>&1
-        restart_apache2="yes"
+    if ! a2query -q -m proxy_fcgi; then
+        a2enmod -q proxy_fcgi
     fi
-    if [ "$restart_apache2" = "yes" ]; then
-        service apache2 restart > /dev/null 2>&1
+    if ! a2query -q -m setenvif; then
+        a2enmod -q setenvif
     fi
+    $BIN/v-restart-web
 fi
 
 # Configure fpm
 update-rc.d php$version-fpm defaults > /dev/null 2>&1
-v_tpl=$(echo "$version" | sed -e 's/[.]//')
+v_tpl=${version//.}
 rm -f /etc/php/$version/fpm/pool.d/*
 cp -f $HESTIA_INSTALL_DIR/php-fpm/dummy.conf /etc/php/$version/fpm/pool.d/
 sed -i "s/9999/99$v_tpl/g" /etc/php/$version/fpm/pool.d/dummy.conf
 
-# Install php templates
-cp -f $HESTIA_INSTALL_DIR/multiphp/$WEB_SYSTEM/PHP-${version//.}.sh \
-    $HESTIA/data/templates/web/$WEB_SYSTEM/
-cp -f $HESTIA_INSTALL_DIR/multiphp/$WEB_SYSTEM/PHP-${version//.}.tpl \
-    $HESTIA/data/templates/web/$WEB_SYSTEM/
-cp -f $HESTIA_INSTALL_DIR/multiphp/$WEB_SYSTEM/PHP-${version//.}.stpl \
-    $HESTIA/data/templates/web/$WEB_SYSTEM/
-chmod a+x $HESTIA/data/templates/web/$WEB_SYSTEM/PHP-${version//.}.sh
-
+# Install backend template
+cp -f $HESTIA_INSTALL_DIR/php-fpm/multiphp.tpl \
+    $HESTIA/data/templates/web/php-fpm/PHP-${version/\./_}.tpl
 
 #----------------------------------------------------------#
 #                       Hestia                             #
 #----------------------------------------------------------#
 
 # Logging
-log_history "installed php $job"
+log_history "installed php $version" '' 'admin'
 log_event "$OK" "$ARGUMENTS"
 
 exit

+ 1 - 1
bin/v-backup-users

@@ -28,7 +28,7 @@ mysqlrepair --all-databases --check --auto-repair > /dev/null 2>&1
 if [ -z "$BACKUP_SYSTEM" ]; then
     exit
 fi
-for user in $(grep '@' /etc/passwd |cut -f1 -d:); do
+for user in $($HESTIA/bin/v-list-sys-users plain); do
     check_suspend=$(grep "SUSPENDED='no'" $HESTIA/data/users/$user/user.conf)
     log=$HESTIA/log/backup.log
     if [ ! -f "$HESTIA/data/users/$user/user.conf" ]; then

+ 1 - 1
bin/v-change-database-owner

@@ -32,7 +32,7 @@ is_object_unsuspended 'user' 'USER' "$user"
 
 # Check owner existance
 owner=$(echo $database | cut -f 1 -d '_')
-if [ ! -e "$HESTIA/data/users/$owner" ]; then
+if [ ! -d "$HESTIA/data/users/$owner" ]; then
     echo "Error: database owner doesn't exist"
     log_event "$E_NOTEXIST" "$ARGUMENTS"
     exit $E_NOTEXIST

+ 1 - 1
bin/v-change-fs-file-permission

@@ -15,7 +15,7 @@ if [ -z "$permissions" ]; then
 fi
 
 # Checking hestia user
-if [ ! -e "$HESTIA/data/users/$user" ]; then
+if [ ! -d "$HESTIA/data/users/$user" ]; then
     echo "Error: hestia user $user doesn't exist"
     exit 3
 fi

+ 5 - 5
bin/v-change-sys-ip-nat

@@ -53,8 +53,8 @@ fi
 
 # Updating WEB configs
 if [ ! -z "$old" ] && [ ! -z "$WEB_SYSTEM" ]; then
-    sed -i "s/$old/$new/" $HESTIA/data/users/*/web.conf
-    for user in $(ls $HESTIA/data/users/); do
+    for user in $($HESTIA/bin/v-list-sys-users plain); do
+        sed -i "s/$old/$new/" $HESTIA/data/users/$user/web.conf
         $BIN/v-rebuild-web-domains $user no
     done
     $BIN/v-restart-dns $restart
@@ -62,9 +62,9 @@ fi
 
 # Updating DNS configs
 if [ ! -z "$old" ] && [ ! -z "$DNS_SYSTEM" ]; then
-    sed -i "s/$old/$new/" $HESTIA/data/users/*/dns.conf
-    sed -i "s/$old/$new/" $HESTIA/data/users/*/dns/*.conf
-    for user in $(ls $HESTIA/data/users/); do
+    for user in $($HESTIA/bin/v-list-sys-users plain); do
+        sed -i "s/$old/$new/" $HESTIA/data/users/$user/dns.conf
+        sed -i "s/$old/$new/" $HESTIA/data/users/$user/dns/*.conf
         $BIN/v-rebuild-dns-domains $user no
     done
     $BIN/v-restart-dns $restart

+ 3 - 3
bin/v-change-sys-ip-owner

@@ -47,7 +47,7 @@ if [ "$ip_owner" != "$user" ]; then
     decrease_user_value "$ip_owner" '$IP_OWNED'
     if [ "$ip_owner" = 'admin' ]; then
         if [ "$ip_status" = 'shared' ]; then
-            for hestia_user in $(ls $HESTIA/data/users); do
+            for hestia_user in $($HESTIA/bin/v-list-sys-users plain); do
                 decrease_user_value "$hestia_user" '$IP_AVAIL'
             done
         else
@@ -61,8 +61,8 @@ if [ "$ip_owner" != "$user" ]; then
     increase_user_value "$user" '$IP_OWNED'
     if [ "$user" = 'admin' ]; then
         if [ "$ip_status" = 'shared' ]; then
-            for user in $(ls $HESTIA/data/users); do
-                increase_user_value "$user" '$IP_AVAIL'
+            for hestia_user in $($HESTIA/bin/v-list-sys-users plain); do
+                increase_user_value "$hestia_user" '$IP_AVAIL'
             done
         else
             increase_user_value 'admin' '$IP_AVAIL'

+ 1 - 1
bin/v-change-sys-language

@@ -52,7 +52,7 @@ fi
 
 # Update language for all existing users if specified
 if [ "$update_users" = "yes" ]; then
-    for user in $(ls $HESTIA/data/users); do
+    for user in $($HESTIA/bin/v-list-sys-users plain); do
         $BIN/v-change-user-language $user $language
     done
 fi

+ 3 - 3
bin/v-change-sys-webmail

@@ -29,7 +29,7 @@ check_hestia_demo_mode
 #----------------------------------------------------------#
 
 # Delete old webmail configuration
-for user in `ls /usr/local/hestia/data/users/`; do
+for user in $($HESTIA/bin/v-list-sys-users plain); do
     for domain in $($BIN/v-list-mail-domains $user plain |cut -f 1); do
         $BIN/v-delete-sys-webmail $user $domain
     done
@@ -39,7 +39,7 @@ done
 $BIN/v-change-sys-config-value 'WEBMAIL_ALIAS' $NEW_ALIAS
 
 # Add new webmail configuration
-for user in `ls /usr/local/hestia/data/users/`; do
+for user in $($HESTIA/bin/v-list-sys-users plain); do
     for domain in $($BIN/v-list-mail-domains $user plain |cut -f 1); do
         $BIN/v-add-sys-webmail $user $domain
     done
@@ -63,7 +63,7 @@ $BIN/v-restart-web $restart
 $BIN/v-restart-proxy $restart
 
 # Logging
-log_history "changed global webmail alias to $NEW_ALIAS"
+log_history "changed global webmail alias to $NEW_ALIAS" '' 'admin'
 log_event "$OK" "$ARGUMENTS"
 
 exit

+ 2 - 1
bin/v-change-web-domain-backend-tpl

@@ -69,7 +69,8 @@ cat $WEBTPL/$WEB_BACKEND/$template.tpl |\
         -e "s|%user%|$user|g"\
         -e "s|%domain%|$domain|g"\
         -e "s|%domain_idn%|$domain_idn|"\
-        -e "s|%backend%|$backend_type|g" > $pool/$backend_type.conf
+        -e "s|%backend%|$backend_type|g"\
+        -e "s|%backend_version%|$backend_version|g" > $pool/$backend_type.conf
 
 # Checking backend pool configuration
 if [ "$backend_type" = "$user" ]; then

+ 1 - 1
bin/v-check-fs-permission

@@ -14,7 +14,7 @@ if [ -z "$src" ]; then
 fi
 
 # Checking hestia user
-if [ ! -e "$HESTIA/data/users/$user" ]; then
+if [ ! -d "$HESTIA/data/users/$user" ]; then
     echo "Error: hestia user $user doesn't exist"
     exit 3
 fi

+ 1 - 1
bin/v-copy-fs-directory

@@ -15,7 +15,7 @@ if [ -z "$dst_dir" ]; then
 fi
 
 # Checking hestia user
-if [ ! -e "$HESTIA/data/users/$user" ]; then
+if [ ! -d "$HESTIA/data/users/$user" ]; then
     echo "Error: hestia user $user doesn't exist"
     exit 3
 fi

+ 1 - 1
bin/v-delete-fs-directory

@@ -15,7 +15,7 @@ if [ -z "$dst_dir" ]; then
 fi
 
 # Checking hestia user
-if [ ! -e "$HESTIA/data/users/$user" ]; then
+if [ ! -d "$HESTIA/data/users/$user" ]; then
     echo "Error: hestia user $user doesn't exist"
     exit 3
 fi

+ 1 - 1
bin/v-delete-fs-file

@@ -15,7 +15,7 @@ if [ -z "$dst_file" ]; then
 fi
 
 # Checking hestia user
-if [ ! -e "$HESTIA/data/users/$user" ]; then
+if [ ! -d "$HESTIA/data/users/$user" ]; then
     echo "Error: hestia user $user doesn't exist"
     exit 3
 fi

+ 5 - 3
bin/v-delete-sys-ip

@@ -128,9 +128,11 @@ fi
 
 if [ "$OWNER" = 'admin' ]; then
     if [ "$STATUS" = 'shared' ]; then
-        for user in $(ls $HESTIA/data/users/); do
-            decrease_user_value "$user" '$IP_AVAIL'
+        for hestia_user in $($HESTIA/bin/v-list-sys-users plain); do
+            decrease_user_value "$hestia_user" '$IP_AVAIL'
         done
+    else
+        decrease_user_value "$OWNER" '$IP_AVAIL'
     fi
 else
     decrease_user_value "$OWNER" '$IP_AVAIL'
@@ -152,7 +154,7 @@ if [ ! -z "$FIREWALL_SYSTEM" ]; then
 fi
 
 # Logging
-log_history "deleted system ip address $ip"
+log_history "deleted system ip address $ip" '' 'admin'
 log_event "$OK" "$ARGUMENTS"
 
 exit

+ 4 - 6
bin/v-delete-web-php

@@ -32,6 +32,9 @@ if [[ ! $version =~ ^[0-9]\.[0-9]+ ]]; then
     exit
 fi
 
+# Remove backend template
+[ -f $HESTIA/data/templates/web/php-fpm/PHP-${version/\./_}.tpl ] && rm -f $HESTIA/data/templates/web/php-fpm/PHP-${version/\./_}.tpl
+
 # Check if php version exists
 if [ ! -f "$php_fpm" ] && [ ! -f "$HESTIA/data/templates/$WEB_SYSTEM/PHP-$version.sh" ]; then
     echo "Version is not installed..."
@@ -75,18 +78,13 @@ if [ -f "$php_fpm" ]; then
     echo "apt-get purge $mph"
 fi
 
-# Install php templates
-rm -f $HESTIA/data/templates/web/$WEB_SYSTEM/PHP-${version//.}.sh
-rm -f $HESTIA/data/templates/web/$WEB_SYSTEM/PHP-${version//.}.tpl
-rm -f $HESTIA/data/templates/web/$WEB_SYSTEM/PHP-${version//.}.stpl
-
 
 #----------------------------------------------------------#
 #                       Hestia                             #
 #----------------------------------------------------------#
 
 # Logging
-log_history "removed php $version"
+log_history "removed php $version" '' 'admin'
 log_event "$OK" "$ARGUMENTS"
 
 exit

+ 1 - 1
bin/v-extract-fs-archive

@@ -15,7 +15,7 @@ if [ -z "$dst_dir" ]; then
 fi
 
 # Checking hestia user
-if [ ! -e "$HESTIA/data/users/$user" ]; then
+if [ ! -d "$HESTIA/data/users/$user" ]; then
     echo "Error: hestia user $user doesn't exist"
     exit 3
 fi

+ 2 - 2
bin/v-generate-api-key

@@ -13,7 +13,7 @@ keygen()
 {
     < /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-32};echo;
 }
-KEYS='$HESTIA/data/keys/'
+KEYS="$HESTIA/data/keys/"
 HASH=$(keygen)
 
 
@@ -22,7 +22,7 @@ HASH=$(keygen)
 #----------------------------------------------------------#
 
 if [ ! -d ${KEYS} ]; then
-  mkdir ${KEYS}
+  mkdir -p ${KEYS}
 fi
 
 if [[ -e ${KEYS}${HASH} ]] ; then

+ 1 - 1
bin/v-get-fs-file-type

@@ -14,7 +14,7 @@ if [ -z "$path" ]; then
 fi
 
 # Checking hestia user
-if [ ! -e "$HESTIA/data/users/$user" ]; then
+if [ ! -d "$HESTIA/data/users/$user" ]; then
     echo "Error: hestia user $user doesn't exist"
     exit 3
 fi

+ 1 - 1
bin/v-list-fs-directory

@@ -14,7 +14,7 @@ if [ -z "$user" ]; then
 fi
 
 # Checking hestia user
-if [ ! -e "$HESTIA/data/users/$user" ]; then
+if [ ! -d "$HESTIA/data/users/$user" ]; then
     echo "Error: hestia user $user doesn't exist"
     exit 3
 fi

+ 1 - 1
bin/v-list-users-stats

@@ -122,7 +122,7 @@ check_args '0' "$#" '[FORMAT]'
 #----------------------------------------------------------#
 
 # Ensure statistics are up to date
-for user in $(ls $HESTIA/data/users); do
+for user in $($HESTIA/bin/v-list-sys-users plain); do
     $BIN/v-update-user-stats $user
 done
 

+ 1 - 1
bin/v-move-fs-directory

@@ -16,7 +16,7 @@ if [ -z "$dst_dir" ]; then
 fi
 
 # Checking hestia user
-if [ ! -e "$HESTIA/data/users/$user" ]; then
+if [ ! -d "$HESTIA/data/users/$user" ]; then
     echo "Error: hestia user $user doesn't exist"
     exit 3
 fi

+ 1 - 1
bin/v-move-fs-file

@@ -16,7 +16,7 @@ if [ -z "$dst_file" ]; then
 fi
 
 # Checking hestia user
-if [ ! -e "$HESTIA/data/users/$user" ]; then
+if [ ! -d "$HESTIA/data/users/$user" ]; then
     echo "Error: hestia user $user doesn't exist"
     exit 3
 fi

+ 1 - 1
bin/v-open-fs-config

@@ -13,7 +13,7 @@ if [ -z "$src_file" ]; then
 fi
 
 # Checking hestia user
-if [ ! -e "$HESTIA/data/users/$user" ]; then
+if [ ! -d "$HESTIA/data/users/$user" ]; then
     echo "Error: hestia user $user doesn't exist"
     exit 3
 fi

+ 1 - 1
bin/v-open-fs-file

@@ -14,7 +14,7 @@ if [ -z "$src_file" ]; then
 fi
 
 # Checking hestia user
-if [ ! -e "$HESTIA/data/users/$user" ]; then
+if [ ! -d "$HESTIA/data/users/$user" ]; then
     echo "Error: hestia user $user doesn't exist"
     exit 3
 fi

+ 1 - 1
bin/v-rebuild-users

@@ -35,7 +35,7 @@ is_object_unsuspended 'user' 'USER' "$user"
 #----------------------------------------------------------#
 
 # Rebuild loop
-for user in $($BIN/v-list-users plain |cut -f 1); do
+for user in $($HESTIA/bin/v-list-sys-users plain); do
     $BIN/v-rebuild-user $user
 done
 

+ 1 - 1
bin/v-search-fs-object

@@ -15,7 +15,7 @@ if [ -z "$object" ]; then
 fi
 
 # Checking hestia user
-if [ ! -e "$HESTIA/data/users/$user" ]; then
+if [ ! -d "$HESTIA/data/users/$user" ]; then
     echo "Error: hestia user $user doesn't exist"
     exit 3
 fi

+ 2 - 2
bin/v-search-object

@@ -84,7 +84,7 @@ OLD_IFS=$IFS
 IFS=$'\n'
 
 # User loop
-for user in $(ls $HESTIA/data/users/); do
+for user in $($HESTIA/bin/v-list-sys-users plain); do
     # Search query
     search=$(grep "$object" \
         $HESTIA/data/users/$user/web.conf \
@@ -242,7 +242,7 @@ case $format in
     json)   json_list_search ;;
     plain)  nohead=1; shell_list_search ;;
     shell)  fields='$USER~$TYPE~$KEY~$RESULT~$ALIAS';
-            shell_list |column -t -s '~' ;;
+            shell_list_search |column -t -s '~' ;;
     *)      check_args '1' '0' 'OBJECT [FORMAT]'
 esac
 

+ 1 - 1
bin/v-update-letsencrypt-ssl

@@ -26,7 +26,7 @@ source $HESTIA/conf/hestia.conf
 lecounter=0
 
 # Checking user certificates
-for user in $($BIN/v-list-users plain |cut -f 1); do
+for user in $($HESTIA/bin/v-list-sys-users plain); do
     USER_DATA=$HESTIA/data/users/$user
 
     for domain in $(search_objects 'web' 'LETSENCRYPT' 'yes' 'DOMAIN'); do

+ 1 - 1
bin/v-update-mail-templates

@@ -25,7 +25,7 @@ cp -rf $HESTIA_INSTALL_DIR/templates/mail $HESTIA/data/templates/
 
 # Rebuild mail domains if mail services are enabled
 if [ ! -z $MAIL_SYSTEM ]; then
-	for user in $($BIN/v-list-sys-users plain); do
+	for user in $($HESTIA/bin/v-list-sys-users plain); do
 		$BIN/v-rebuild-mail-domains $user no
 	done
 fi

+ 2 - 2
bin/v-update-sys-ip

@@ -63,7 +63,7 @@ if [ ! -z "$new" ]; then
             mv $old.conf $new.conf
             sed -i "s/$old/$new/g" $new.conf
         fi
-        for user in $(ls $HESTIA/data/users/); do
+        for user in $($HESTIA/bin/v-list-sys-users plain); do
             sed -i "s/$old/$new/g" $HESTIA/data/users/$user/web.conf
             $BIN/v-rebuild-web-domains $user no
         done
@@ -73,7 +73,7 @@ if [ ! -z "$new" ]; then
 
     # Updating DNS
     if [ ! -z "$DNS_SYSTEM" ]; then
-        for user in `ls /usr/local/hestia/data/users/`; do
+        for user in $($HESTIA/bin/v-list-sys-users plain); do
             sed -i "s/$old/$new/g" $HESTIA/data/users/$user/dns.conf
             sed -i "s/$old/$new/g" $HESTIA/data/users/$user/dns/*.conf
             $BIN/v-rebuild-dns-domains $user no

+ 2 - 2
bin/v-update-user-counters

@@ -34,7 +34,7 @@ fi
 
 # Creating user_list
 if [ -z "$user" ]; then
-    user_list=$(ls $HESTIA/data/users)
+    user_list=$($HESTIA/bin/v-list-sys-users plain)
 else
     user_list="$user"
 fi
@@ -82,7 +82,7 @@ for user in $user_list; do
     if [ "$user" = 'admin' ]; then
         spnd=$(grep "SUSPENDED='yes'" $HESTIA/data/users/*/user.conf | wc -l)
         SUSPENDED_USERS=$spnd
-        U_USERS=$(ls $HESTIA/data/users/|wc -l)
+        U_USERS=$($HESTIA/bin/v-list-sys-users plain|wc -l)
     fi
 
     # Checking ip

+ 1 - 1
bin/v-update-user-package

@@ -30,7 +30,7 @@ is_package_valid
 #                       Action                             #
 #----------------------------------------------------------#
 
-for user in $(ls $HESTIA/data/users); do
+for user in $($HESTIA/bin/v-list-sys-users plain); do
     check_package=$(grep "PACKAGE='$package'" $USER_DATA/$user/user.conf)
     if [ ! -z "$check_package" ]; then
         $BIN/v-change-user-package $user $package 'yes'

+ 1 - 1
bin/v-update-user-stats

@@ -39,7 +39,7 @@ fi
 
 # Creating user_list
 if [ -z "$user" ]; then
-    user_list=$(grep '@' /etc/passwd |cut -f1 -d:)
+    user_list=$($HESTIA/bin/v-list-sys-users plain)
 else
     user_list="$user"
 fi

+ 7 - 2
bin/v-update-web-templates

@@ -27,6 +27,11 @@ if [ -d "${WEBTPL}" ]; then
     rm -rf "${WEBTPL}/unassigned" 2>/dev/null
 fi
 
+for php_ver in $(ls /etc/php/); do
+    [ ! -d "/etc/php/$php_ver/fpm/pool.d/" ] && continue
+    cp -f "$HESTIA_INSTALL_DIR/php-fpm/multiphp.tpl"  ${WEBTPL}/php-fpm/PHP-${php_ver/\./_}.tpl
+done
+
 for webtpl_folder in $(ls $HESTIA_INSTALL_DIR/templates/web/* -d 2>/dev/null | egrep -v '/(nginx)$' ); do
     cp -rf "${webtpl_folder}" "${WEBTPL}/"
 done
@@ -35,7 +40,7 @@ done
 
 # Update Multi-PHP templates
 php_versions=$(ls /etc/php/*/fpm -d 2>/dev/null | wc -l)
-if [ "$php_versions" -gt 1 ]; then
+if [ "$php_versions" -gt 1 ] && [ -z "$WEB_BACKEND" ]; then
     for v in $(ls /etc/php/); do
         if [ ! -d "/etc/php/$v/fpm/pool.d/" ]; then
             continue
@@ -53,7 +58,7 @@ if [ "$php_versions" -gt 1 ]; then
     fi
 fi
 
-if [ "$PROXY_SYSTEM" = 'nginx' ] || [ "$php_versions" -le 1 ]; then
+if [ "$PROXY_SYSTEM" = 'nginx' ] || [ "$WEB_BACKEND" = "php-fpm" ]; then
     cp -rf "${HESTIA_INSTALL_DIR}/templates/web/nginx" "${WEBTPL}/"
 fi
 

+ 17 - 13
func/domain.sh

@@ -85,25 +85,21 @@ is_web_alias_new() {
 # Prepare web backend
 prepare_web_backend() {
     pool=$(find -L /etc/php/ -name "$domain.conf" -exec dirname {} \;)
-
     # Check if multiple-PHP installed
     regex="socket-(\d+)_(\d+)"
-    if [[ $template =~ ^socket-([0-9])\_([0-9])$ ]]
-    then
-        version="${BASH_REMATCH[1]}.${BASH_REMATCH[2]}"
-        pool=$(find -L /etc/php/$version -type d \( -name "pool.d" -o -name "*fpm.d" \))
+    if [[ $template =~ ^PHP-([0-9])\_([0-9])$ ]]; then
+        backend_version="${BASH_REMATCH[1]}.${BASH_REMATCH[2]}"
+        pool=$(find -L /etc/php/$backend_version -type d \( -name "pool.d" -o -name "*fpm.d" \))
     else
-        if [ "$pool" == "" ]
-        then
-            version=`echo "<?php echo (float)phpversion();" | php`
-            pool=$(find -L /etc/php/$version -type d \( -name "pool.d" -o -name "*fpm.d" \))
+        if [ -z "$pool" ] || [ -z "$BACKEND" ]; then 
+            backend_version=$(php -r "echo (float)phpversion();")
+            pool=$(find -L /etc/php/$backend_version -type d \( -name "pool.d" -o -name "*fpm.d" \))
         fi
     fi
  
     if [ ! -e "$pool" ]; then
         check_result $E_NOTEXIST "php-fpm pool doesn't exist"
     fi
-
     backend_type="$domain"
     if [ "$WEB_BACKEND_POOL" = 'user' ]; then
         backend_type="$user"
@@ -197,7 +193,15 @@ add_web_config() {
     domain_idn=$domain
     format_domain_idn
 
-    cat $WEBTPL/$1/$WEB_BACKEND/$2 | \
+    WEBTPL_LOCATION="$WEBTPL/$1"
+    if [ ! -z "$WEB_BACKEND" ] && [ -d "$WEBTPL_LOCATION/$WEB_BACKEND" ]; then
+        if [ -f "$WEBTPL_LOCATION/$WEB_BACKEND/$2" ]; then
+            # check for backend specific template
+            WEBTPL_LOCATION="$WEBTPL/$1/$WEB_BACKEND"
+        fi
+    fi
+
+    cat "${WEBTPL_LOCATION}/$2" | \
         sed -e "s|%ip%|$local_ip|g" \
             -e "s|%domain%|$domain|g" \
             -e "s|%domain_idn%|$domain_idn|g" \
@@ -274,8 +278,8 @@ add_web_config() {
     fi
     
     trigger="${2/.*pl/.sh}"
-    if [ -x "$WEBTPL/$1/$WEB_BACKEND/$trigger" ]; then
-        $WEBTPL/$1/$WEB_BACKEND/$trigger \
+    if [ -x "${WEBTPL_LOCATION}/$trigger" ]; then
+        $WEBTPL_LOCATION/$trigger \
             $user $domain $local_ip $HOMEDIR \
             $HOMEDIR/$user/web/$domain/public_html
     fi

+ 5 - 0
func/main.sh

@@ -78,6 +78,11 @@ log_history() {
     cmd=$1
     undo=${2-no}
     log_user=${3-$user}
+
+    if ! $BIN/v-list-user "$log_user" >/dev/null; then
+        return $E_NOTEXIST
+    fi
+
     log=$HESTIA/data/users/$log_user/history.log
     touch $log
     if [ '99' -lt "$(wc -l $log |cut -f 1 -d ' ')" ]; then

+ 1 - 1
func/upgrade.sh

@@ -198,7 +198,7 @@ upgrade_set_version() {
 }
 
 upgrade_rebuild_users() {
-    for user in `ls /usr/local/hestia/data/users/`; do
+    for user in $($HESTIA/bin/v-list-sys-users plain); do
         echo "(*) Rebuilding domains and account for user: $user..."
         if [ ! -z "$WEB_SYSTEM" ]; then
             $BIN/v-rebuild-web-domains $user 'no' >/dev/null 2>&1

+ 31 - 0
install/deb/php-fpm/multiphp.tpl

@@ -0,0 +1,31 @@
+[%domain%]
+
+listen = /run/php/php%backend_version%-fpm-%domain%.sock
+listen.owner = %user%
+listen.group = www-data
+listen.mode = 0660
+
+user = %user%
+group = %user%
+
+pm = ondemand
+pm.max_children = 8
+pm.max_requests = 4000
+pm.process_idle_timeout = 10s
+pm.status_path = /status
+
+php_admin_value[upload_tmp_dir] = /home/%user%/tmp
+php_admin_value[session.save_path] = /home/%user%/tmp
+php_admin_value[open_basedir] = /home/%user%/web/%domain%/public_html:/home/%user%/web/%domain%/public_shtml:/home/%user%/tmp:/bin:/usr/bin:/usr/local/bin:/var/www/html:/tmp:/usr/share:/etc/phpMyAdmin:/etc/phpmyadmin:/var/lib/phpmyadmin:/etc/roundcubemail
+php_admin_value[upload_max_filesize] = 80M
+php_admin_value[max_execution_time] = 30
+php_admin_value[post_max_size] = 80M
+php_admin_value[memory_limit] = 256M
+php_admin_value[sendmail_path] = \"/usr/sbin/sendmail -t -i -f info@%domain%\"
+php_admin_flag[mysql.allow_persistent] = off
+php_admin_flag[safe_mode] = off
+
+env[PATH] = /usr/local/bin:/usr/bin:/bin
+env[TMP] = /home/%user%/tmp
+env[TMPDIR] = /home/%user%/tmp
+env[TEMP] = /home/%user%/tmp

+ 44 - 0
install/deb/templates/web/apache2/php-fpm/default.stpl

@@ -0,0 +1,44 @@
+<VirtualHost %ip%:%web_ssl_port%>
+
+    ServerName %domain_idn%
+    %alias_string%
+    ServerAdmin %email%
+    DocumentRoot %sdocroot%
+    ScriptAlias /cgi-bin/ %home%/%user%/web/%domain%/cgi-bin/
+    Alias /vstats/ %home%/%user%/web/%domain%/stats/
+    Alias /error/ %home%/%user%/web/%domain%/document_errors/
+    #SuexecUserGroup %user% %group%
+    CustomLog /var/log/%web_system%/domains/%domain%.bytes bytes
+    CustomLog /var/log/%web_system%/domains/%domain%.log combined
+    ErrorLog /var/log/%web_system%/domains/%domain%.error.log
+    <Directory %home%/%user%/web/%domain%/stats>
+        AllowOverride All
+    </Directory>
+    <Directory %sdocroot%>
+        AllowOverride All
+        SSLRequireSSL
+        Options +Includes -Indexes +ExecCGI
+	</Directory>
+    SSLEngine on
+    SSLVerifyClient none
+    SSLCertificateFile %ssl_crt%
+    SSLCertificateKeyFile %ssl_key%
+    %ssl_ca_str%SSLCertificateChainFile %ssl_ca%
+#    <IfModule mod_ruid2.c>
+#        RMode config
+#        RUidGid %user% %group%
+#        RGroups www-data
+#    </IfModule>
+#    <IfModule itk.c>
+#        AssignUserID %user% %group%
+#    </IfModule>
+
+    <FilesMatch \.php$>
+        SetHandler "proxy:%backend_lsnr%|fcgi://localhost/"
+    </FilesMatch>
+    SetEnvIf Authorization .+ HTTP_AUTHORIZATION=$0
+
+    IncludeOptional %home%/%user%/conf/web/%domain%/%web_system%.ssl.conf_*
+
+</VirtualHost>
+

+ 41 - 0
install/deb/templates/web/apache2/php-fpm/default.tpl

@@ -0,0 +1,41 @@
+<VirtualHost %ip%:%web_port%>
+
+    ServerName %domain_idn%
+    %alias_string%
+    ServerAdmin %email%
+    DocumentRoot %docroot%
+    ScriptAlias /cgi-bin/ %home%/%user%/web/%domain%/cgi-bin/
+    Alias /vstats/ %home%/%user%/web/%domain%/stats/
+    Alias /error/ %home%/%user%/web/%domain%/document_errors/
+    #SuexecUserGroup %user% %group%
+    CustomLog /var/log/%web_system%/domains/%domain%.bytes bytes
+    CustomLog /var/log/%web_system%/domains/%domain%.log combined
+    ErrorLog /var/log/%web_system%/domains/%domain%.error.log
+        
+    IncludeOptional %home%/%user%/conf/web/%domain%/apache2.forcessl.conf*
+    
+    <Directory %home%/%user%/web/%domain%/stats>
+        AllowOverride All
+    </Directory>
+    <Directory %sdocroot%>
+        AllowOverride All
+        Options +Includes -Indexes +ExecCGI
+    </Directory>
+#    <IfModule mod_ruid2.c>
+#        RMode config
+#        RUidGid %user% %group%
+#        RGroups www-data
+#    </IfModule>
+#    <IfModule itk.c>
+#        AssignUserID %user% %group%
+#    </IfModule>
+
+    <FilesMatch \.php$>
+        SetHandler "proxy:%backend_lsnr%|fcgi://localhost/"
+    </FilesMatch>
+    SetEnvIf Authorization .+ HTTP_AUTHORIZATION=$0
+
+    IncludeOptional %home%/%user%/conf/web/%domain%/%web_system%.conf_*
+
+</VirtualHost>
+

+ 5 - 2
install/deb/templates/web/php-fpm/default.tpl

@@ -1,6 +1,9 @@
 [%backend%]
-listen = 127.0.0.1:%backend_port%
-listen.allowed_clients = 127.0.0.1
+
+listen = /run/php/php%backend_version%-fpm-%domain%.sock
+listen.owner = %user%
+listen.group = www-data
+listen.mode = 0660
 
 user = %user%
 group = %user%

+ 26 - 91
install/hst-install-debian.sh

@@ -261,12 +261,8 @@ set_default_port '8083'
 set_default_lang 'en'
 
 # Checking software conflicts
-if [ "$phpfpm" = 'yes' ]; then
-    apache='no'
-    nginx='yes'
-fi
 if [ "$multiphp" = 'yes' ]; then
-    phpfpm='no'
+    phpfpm='yes'
 fi
 if [ "$proftpd" = 'yes' ]; then
     vsftpd='no'
@@ -293,6 +289,11 @@ if [ ! -z "$(grep ^admin: /etc/passwd /etc/group)" ] && [ -z "$force" ]; then
     check_result 1 "User admin exists"
 fi
 
+# Check if a default webserver was set
+if [ $apache = 'no' ] && [ $nginx = 'no' ]; then
+    check_result 1 "No web server was selected"
+fi
+
 # Clear the screen once launch permissions have been verified
 clear
 
@@ -717,32 +718,6 @@ rm -rf $HESTIA > /dev/null 2>&1
 #                     Package Includes                     #
 #----------------------------------------------------------#
 
-if [ "$multiphp" = 'yes' ]; then
-    fpm_added=false
-    for v in "${multiphp_v[@]}"; do
-        if [ "$v" = "$fpm_v" ]; then
-            fpm_added=true
-        fi
-        mph="php$v-mbstring php$v-bcmath php$v-cli php$v-curl php$v-fpm
-             php$v-gd php$v-intl php$v-mysql php$v-soap php$v-xml php$v-zip
-             php$v-mbstring php$v-json php$v-bz2 php$v-pspell php$v-imagick"
-        # Check is version is 7.1 or below to add mcrypt
-        if [[ `echo "$v 7.2" | awk '{print ($1 < $2)}'` == 1 ]]; then 
-            mph="$mph php$v-mcrypt"
-        fi
-        software="$software $mph"
-    done
-    if [ "$fpm_added" = false ]; then
-        fpm="php$fpm_v php$fpm_v-common php$fpm_v-bcmath php$fpm_v-cli
-             php$fpm_v-curl php$fpm_v-fpm php$fpm_v-gd php$fpm_v-intl
-             php$fpm_v-mysql php$fpm_v-soap php$fpm_v-xml php$fpm_v-zip
-             php$fpm_v-mbstring php$fpm_v-json php$fpm_v-bz2 php$fpm_v-pspell
-             php$fpm_v-imagick"
-        software="$software $fpm"
-        multiphp+=("$fpm_v")
-    fi
-fi
-
 if [ "$phpfpm" = 'yes' ]; then
     fpm="php$fpm_v php$fpm_v-common php$fpm_v-bcmath php$fpm_v-cli
          php$fpm_v-curl php$fpm_v-fpm php$fpm_v-gd php$fpm_v-intl
@@ -812,12 +787,6 @@ if [ "$mysql" = 'no' ]; then
     software=$(echo "$software" | sed -e 's/mariadb-client//')
     software=$(echo "$software" | sed -e 's/mariadb-common//')
     software=$(echo "$software" | sed -e 's/php-mysql//')
-    if [ "$multiphp" = 'yes' ]; then
-        for v in "${multiphp_v[@]}"; do
-            software=$(echo "$software" | sed -e "s/php$v-mysql//")
-            software=$(echo "$software" | sed -e "s/php$v-bz2//")
-        done
-    fi
     if [ "$phpfpm" = 'yes' ]; then
         software=$(echo "$software" | sed -e "s/php$fpm_v-mysql//")
     fi
@@ -827,11 +796,6 @@ if [ "$postgresql" = 'no' ]; then
     software=$(echo "$software" | sed -e 's/postgresql-contrib//')
     software=$(echo "$software" | sed -e 's/postgresql//')
     software=$(echo "$software" | sed -e 's/php-pgsql//')
-    if [ "$multiphp" = 'yes' ]; then
-        for v in "${multiphp_v[@]}"; do
-            software=$(echo "$software" | sed -e "s/php$v-pgsql//")
-        done
-    fi
     if [ "$phpfpm" = 'yes' ]; then
         software=$(echo "$software" | sed -e "s/php$v-pgsql//")
     fi
@@ -1046,18 +1010,19 @@ if [ "$apache" = 'no' ] && [ "$nginx"  = 'yes' ]; then
     echo "WEB_PORT='80'" >> $HESTIA/conf/hestia.conf
     echo "WEB_SSL_PORT='443'" >> $HESTIA/conf/hestia.conf
     echo "WEB_SSL='openssl'"  >> $HESTIA/conf/hestia.conf
-    if [ "$release" -eq 9 ]; then
-        if [ "$phpfpm" = 'yes' ]; then
-            echo "WEB_BACKEND='php-fpm'" >> $HESTIA/conf/hestia.conf
-        fi
-    else
-        if [ "$phpfpm" = 'yes' ]; then
-            echo "WEB_BACKEND='php5-fpm'" >> $HESTIA/conf/hestia.conf
-        fi
-    fi
     echo "STATS_SYSTEM='awstats'" >> $HESTIA/conf/hestia.conf
 fi
 
+if [ "$release" -ge 9 ] || [ "$multiphp" = 'yes' ]; then
+    if [ "$phpfpm" = 'yes' ]; then
+        echo "WEB_BACKEND='php-fpm'" >> $HESTIA/conf/hestia.conf
+    fi
+else
+    if [ "$phpfpm" = 'yes' ]; then
+        echo "WEB_BACKEND='php5-fpm'" >> $HESTIA/conf/hestia.conf
+    fi
+fi
+
 # FTP stack
 if [ "$vsftpd" = 'yes' ]; then
     echo "FTP_SYSTEM='vsftpd'" >> $HESTIA/conf/hestia.conf
@@ -1173,27 +1138,6 @@ if [ "$nginx" = 'yes' ]; then
     cp -f $HESTIA_INSTALL_DIR/logrotate/nginx /etc/logrotate.d/
     mkdir -p /etc/nginx/conf.d/domains
     mkdir -p /var/log/nginx/domains
-    if [ "$apache" = 'no' ] && [ "$multiphp" = 'yes' ]; then
-        echo "(*) Configuring Multi-PHP for NGINX..."
-        rm -fr $HESTIA/data/templates/web/nginx/*
-        for v in "${multiphp_v[@]}"; do
-            update-rc.d php$v-fpm defaults > /dev/null 2>&1
-            cp -r /etc/php/$v/ /root/hst_install_backups/php$v/
-            rm -f /etc/php/$v/fpm/pool.d/*
-            v_tpl=$(echo "$v" | sed -e 's/[.]//')
-            cp -f $HESTIA_INSTALL_DIR/multiphp/nginx/PHP-$v_tpl.* $HESTIA/data/templates/web/nginx/
-            cp -f $HESTIA_INSTALL_DIR/php-fpm/dummy.conf /etc/php/$v/fpm/pool.d/
-            sed -i "s/9999/99$v_tpl/g" /etc/php/$v/fpm/pool.d/dummy.conf
-        done
-        cp -f $HESTIA_INSTALL_DIR/php-fpm/www.conf /etc/php/$fpm_v/fpm/pool.d/
-        chmod a+x $HESTIA/data/templates/web/nginx/*.sh
-        fpm_tpl=$(echo "$fpm_v" | sed -e 's/[.]//')
-        ln -s $HESTIA/data/templates/web/nginx/PHP-$fpm_tpl.sh $HESTIA/data/templates/web/nginx/default.sh
-        ln -s $HESTIA/data/templates/web/nginx/PHP-$fpm_tpl.tpl $HESTIA/data/templates/web/nginx/default.tpl
-        ln -s $HESTIA/data/templates/web/nginx/PHP-$fpm_tpl.stpl $HESTIA/data/templates/web/nginx/default.stpl
-        systemctl start php$fpm_v-fpm >> $LOG
-        check_result $? "php$fpm_v-fpm start failed"
-    fi
 
     # Update dns servers in nginx.conf
     dns_resolver=$(cat /etc/resolv.conf | grep -i '^nameserver' | cut -d ' ' -f2 | tr '\r\n' ' ' | xargs)
@@ -1238,25 +1182,6 @@ if [ "$apache" = 'yes' ]; then
     chmod a+x /var/log/apache2
     chmod 640 /var/log/apache2/access.log /var/log/apache2/error.log
     chmod 751 /var/log/apache2/domains
-    if [ "$multiphp" = 'yes' ] ; then
-        echo "(*) Configuring Multi-PHP for Apache..."
-        a2enmod proxy_fcgi setenvif > /dev/null 2>&1
-        for v in "${multiphp_v[@]}"; do
-            a2enconf php$v-fpm-fpm > /dev/null 2>&1
-            update-rc.d php$v-fpm defaults > /dev/null 2>&1
-            cp -r /etc/php/$v/ /root/hst_install_backups/php$v/
-            rm -f /etc/php/$v/fpm/pool.d/*
-            v_tpl=$(echo "$v" | sed -e 's/[.]//')
-            cp -f $HESTIA_INSTALL_DIR/multiphp/apache2/PHP-$v_tpl.* $HESTIA/data/templates/web/apache2/
-            cp -f $HESTIA_INSTALL_DIR/php-fpm/dummy.conf /etc/php/$v/fpm/pool.d/
-            sed -i "s/9999/99$v_tpl/g" /etc/php/$v/fpm/pool.d/dummy.conf
-        done
-        chmod a+x $HESTIA/data/templates/web/apache2/*.sh
-        if [ "$release" = '8' ]; then
-            sed -i 's/#//g' $HESTIA/data/templates/web/apache2/*.tpl
-            sed -i 's/#//g' $HESTIA/data/templates/web/apache2/*.stpl
-        fi
-    fi
 
     update-rc.d apache2 defaults > /dev/null 2>&1
     systemctl start apache2 >> $LOG
@@ -1271,8 +1196,18 @@ fi
 #                     Configure PHP-FPM                    #
 #----------------------------------------------------------#
 
+if [ "$multiphp" = 'yes' ] ; then
+    for v in "${multiphp_v[@]}"; do
+        cp -r /etc/php/$v/ /root/hst_install_backups/php$v/
+        rm -f /etc/php/$v/fpm/pool.d/*
+
+        $HESTIA/bin/v-add-web-php "$v"
+    done
+fi
+
 if [ "$phpfpm" = 'yes' ]; then
     echo "(*) Configuring PHP-FPM..."
+    $HESTIA/bin/v-add-web-php "$fpm_v"
     cp -f $HESTIA_INSTALL_DIR/php-fpm/www.conf /etc/php/$fpm_v/fpm/pool.d/www.conf
     update-rc.d php$fpm_v-fpm defaults > /dev/null 2>&1
     systemctl start php$fpm_v-fpm >> $LOG

+ 21 - 81
install/hst-install-ubuntu.sh

@@ -234,12 +234,9 @@ set_default_port '8083'
 set_default_lang 'en'
 
 # Checking software conflicts
-if [ "$phpfpm" = 'yes' ]; then
-    apache='no'
-    nginx='yes'
-fi
+
 if [ "$multiphp" = 'yes' ]; then
-    phpfpm='no'
+    phpfpm='yes'
 fi
 if [ "$proftpd" = 'yes' ]; then
     vsftpd='no'
@@ -266,6 +263,11 @@ if [ ! -z "$(grep ^admin: /etc/passwd /etc/group)" ] && [ -z "$force" ]; then
     check_result 1 "User admin exists"
 fi
 
+# Check if a default webserver was set
+if [ $apache = 'no' ] && [ $nginx = 'no' ]; then
+    check_result 1 "No web server was selected"
+fi
+
 # Clear the screen once launch permissions have been verified
 clear
 
@@ -670,32 +672,6 @@ rm -rf $HESTIA > /dev/null 2>&1
 #                     Package Includes                     #
 #----------------------------------------------------------#
 
-if [ "$multiphp" = 'yes' ]; then
-    fpm_added=false
-    for v in "${multiphp_v[@]}"; do
-        if [ "$v" = "$fpm_v" ]; then
-            fpm_added=true
-        fi
-        mph="php$v-mbstring php$v-bcmath php$v-cli php$v-curl php$v-fpm
-             php$v-gd php$v-intl php$v-mysql php$v-soap php$v-xml php$v-zip
-             php$v-mbstring php$v-json php$v-bz2 php$v-pspell php$v-imagick"
-        # Check is version is 7.1 or below to add mcrypt
-        if [[ `echo "$v 7.2" | awk '{print ($1 < $2)}'` == 1 ]]; then
-            mph="$mph php$v-mcrypt"
-        fi
-        software="$software $mph"
-    done
-    if [ "$fpm_added" = false ]; then
-        fpm="php$fpm_v php$fpm_v-common php$fpm_v-bcmath php$fpm_v-cli
-             php$fpm_v-curl php$fpm_v-fpm php$fpm_v-gd php$fpm_v-intl
-             php$fpm_v-mysql php$fpm_v-soap php$fpm_v-xml php$fpm_v-zip
-             php$fpm_v-mbstring php$fpm_v-json php$fpm_v-bz2 php$fpm_v-pspell
-             php$fpm_v-imagick"
-        software="$software $fpm"
-        multiphp+=("$fpm_v")
-    fi
-fi
-
 if [ "$phpfpm" = 'yes' ]; then
     fpm="php$fpm_v php$fpm_v-common php$fpm_v-bcmath php$fpm_v-cli
          php$fpm_v-curl php$fpm_v-fpm php$fpm_v-gd php$fpm_v-intl
@@ -765,12 +741,6 @@ if [ "$mysql" = 'no' ]; then
     software=$(echo "$software" | sed -e 's/mariadb-client//')
     software=$(echo "$software" | sed -e 's/mariadb-common//')
     software=$(echo "$software" | sed -e 's/php-mysql//')
-    if [ "$multiphp" = 'yes' ]; then
-        for v in "${multiphp_v[@]}"; do
-            software=$(echo "$software" | sed -e "s/php$v-mysql//")
-            software=$(echo "$software" | sed -e "s/php$v-bz2//")
-        done
-    fi
     if [ "$phpfpm" = 'yes' ]; then
         software=$(echo "$software" | sed -e "s/php$fpm_v-mysql//")
     fi
@@ -780,11 +750,6 @@ if [ "$postgresql" = 'no' ]; then
     software=$(echo "$software" | sed -e 's/postgresql-contrib//')
     software=$(echo "$software" | sed -e 's/postgresql//')
     software=$(echo "$software" | sed -e 's/php-pgsql//')
-    if [ "$multiphp" = 'yes' ]; then
-        for v in "${multiphp_v[@]}"; do
-            software=$(echo "$software" | sed -e "s/php$v-pgsql//")
-        done
-    fi
     if [ "$phpfpm" = 'yes' ]; then
         software=$(echo "$software" | sed -e "s/php$v-pgsql//")
     fi
@@ -1005,12 +970,13 @@ if [ "$apache" = 'no' ] && [ "$nginx"  = 'yes' ]; then
     echo "WEB_PORT='80'" >> $HESTIA/conf/hestia.conf
     echo "WEB_SSL_PORT='443'" >> $HESTIA/conf/hestia.conf
     echo "WEB_SSL='openssl'"  >> $HESTIA/conf/hestia.conf
-    if [ "$phpfpm" = 'yes' ]; then
-        echo "WEB_BACKEND='php-fpm'" >> $HESTIA/conf/hestia.conf
-    fi
     echo "STATS_SYSTEM='awstats'" >> $HESTIA/conf/hestia.conf
 fi
 
+if [ "$phpfpm" = 'yes' ] || [ "$multiphp" = 'yes' ]; then
+    echo "WEB_BACKEND='php-fpm'" >> $HESTIA/conf/hestia.conf
+fi
+
 # FTP stack
 if [ "$vsftpd" = 'yes' ]; then
     echo "FTP_SYSTEM='vsftpd'" >> $HESTIA/conf/hestia.conf
@@ -1131,27 +1097,6 @@ if [ "$nginx" = 'yes' ]; then
     cp -f $HESTIA_INSTALL_DIR/logrotate/nginx /etc/logrotate.d/
     mkdir -p /etc/nginx/conf.d/domains
     mkdir -p /var/log/nginx/domains
-    if [ "$apache" = 'no' ] && [ "$multiphp" = 'yes' ]; then
-        echo "(*) Configuring Multi-PHP for NGINX..."
-        rm -fr $HESTIA/data/templates/web/nginx/*
-        for v in "${multiphp_v[@]}"; do
-            update-rc.d php$v-fpm defaults > /dev/null 2>&1
-            cp -r /etc/php/$v/ /root/hst_install_backups/php$v/
-            rm -f /etc/php/$v/fpm/pool.d/*
-            v_tpl=$(echo "$v" | sed -e 's/[.]//')
-            cp -f $HESTIA_INSTALL_DIR/multiphp/nginx/PHP-$v_tpl.* $HESTIA/data/templates/web/nginx/
-            cp -f $HESTIA_INSTALL_DIR/php-fpm/dummy.conf /etc/php/$v/fpm/pool.d/
-            sed -i "s/9999/99$v_tpl/g" /etc/php/$v/fpm/pool.d/dummy.conf
-        done
-        cp -f $HESTIA_INSTALL_DIR/php-fpm/www.conf /etc/php/$fpm_v/fpm/pool.d/
-        chmod a+x $HESTIA/data/templates/web/nginx/*.sh
-        fpm_tpl=$(echo "$fpm_v" | sed -e 's/[.]//')
-        ln -s $HESTIA/data/templates/web/nginx/PHP-$fpm_tpl.sh $HESTIA/data/templates/web/nginx/default.sh
-        ln -s $HESTIA/data/templates/web/nginx/PHP-$fpm_tpl.tpl $HESTIA/data/templates/web/nginx/default.tpl
-        ln -s $HESTIA/data/templates/web/nginx/PHP-$fpm_tpl.stpl $HESTIA/data/templates/web/nginx/default.stpl
-        systemctl start php$fpm_v-fpm >> $LOG
-        check_result $? "php$fpm_v-fpm start failed"
-    fi
 
     # Update dns servers in nginx.conf
     dns_resolver=$(cat /etc/resolv.conf | grep -i '^nameserver' | cut -d ' ' -f2 | tr '\r\n' ' ' | xargs)
@@ -1196,21 +1141,6 @@ if [ "$apache" = 'yes' ]; then
     chmod a+x /var/log/apache2
     chmod 640 /var/log/apache2/access.log /var/log/apache2/error.log
     chmod 751 /var/log/apache2/domains
-    if [ "$multiphp" = 'yes' ] ; then
-        echo "(*) Configuring Multi-PHP for Apache..."
-        a2enmod proxy_fcgi setenvif > /dev/null 2>&1
-        for v in "${multiphp_v[@]}"; do
-            a2enconf php$v-fpm-fpm > /dev/null 2>&1
-            update-rc.d php$v-fpm defaults > /dev/null 2>&1
-            cp -r /etc/php/$v/ /root/hst_install_backups/php$v/
-            rm -f /etc/php/$v/fpm/pool.d/*
-            v_tpl=$(echo "$v" | sed -e 's/[.]//')
-            cp -f $HESTIA_INSTALL_DIR/multiphp/apache2/PHP-$v_tpl.* $HESTIA/data/templates/web/apache2/
-            cp -f $HESTIA_INSTALL_DIR/php-fpm/dummy.conf /etc/php/$v/fpm/pool.d/
-            sed -i "s/9999/99$v_tpl/g" /etc/php/$v/fpm/pool.d/dummy.conf
-        done
-        chmod a+x $HESTIA/data/templates/web/apache2/*.sh
-    fi
 
     update-rc.d apache2 defaults > /dev/null 2>&1
     systemctl start apache2 >> $LOG
@@ -1225,8 +1155,18 @@ fi
 #                     Configure PHP-FPM                    #
 #----------------------------------------------------------#
 
+if [ "$multiphp" = 'yes' ] ; then
+    for v in "${multiphp_v[@]}"; do
+        cp -r /etc/php/$v/ /root/hst_install_backups/php$v/
+        rm -f /etc/php/$v/fpm/pool.d/*
+
+        $HESTIA/bin/v-add-web-php "$v"
+    done
+fi
+
 if [ "$phpfpm" = 'yes' ]; then
     echo "(*) Configuring PHP-FPM..."
+    $HESTIA/bin/v-add-web-php "$fpm_v"
     cp -f $HESTIA_INSTALL_DIR/php-fpm/www.conf /etc/php/$fpm_v/fpm/pool.d/www.conf
     update-rc.d php$fpm_v-fpm defaults > /dev/null 2>&1
     systemctl start php$fpm_v-fpm >> $LOG

+ 127 - 0
install/upgrade/manual/migrate-190718-multiphp.sh

@@ -0,0 +1,127 @@
+#!/bin/bash
+
+# Includes
+source $HESTIA/func/main.sh
+source $HESTIA/conf/hestia.conf
+
+#
+# Migrate legacy multiphp to full php-fpm backend
+#
+# nginx+fpm (default)
+#   nothing to be done here,
+#   (Adding new php backends will make them available on edit/web)
+#
+# nginx+multiphp,
+# nginx+apache+multiphp,
+# apache+multiphp:
+#   Change Hestia WEB_BACKEND from null to php-fpm
+#   Create backend templates ex: PHP-7_3, PHP-5_6 (in $HESTIA/data/templates/web/php-fpm/)
+#   v-update-web-templates
+#   Loop trough all web domains
+#   If official multiphp tpl is used ex: PHP-72, then change backend tpl and set app web template to default
+#       ( old default.tpl backend maps to PHP-7_3 )
+#   If not, parse php version from tpl file , fallback to latest version,
+#   Copy all non-official tpls to php-fpm folder (as app web template includin bash script if present)
+#
+# a2 (non-fpm) or nginx+a2(non-fpm)
+# - Skipped
+#
+
+DEFAULT_BTPL="PHP-7_3"
+num_php_versions=$(ls -d /etc/php/*/fpm/pool.d 2>/dev/null |wc -l)
+echo $num_php_versions
+
+if [ "$num_php_versions" -gt 1 ] && [ -z "$WEB_BACKEND" ]; then
+    # Legacy multiphp
+
+    echo $num_php_versions
+    sed -i "/^WEB_BACKEND=/d" $HESTIA/conf/hestia.conf
+    echo "WEB_BACKEND='php-fpm'" >> $HESTIA/conf/hestia.conf
+
+    for php_ver in $(ls /etc/php/); do
+        [ ! -d "/etc/php/$php_ver/fpm/pool.d/" ] && continue
+        cp -f "$HESTIA_INSTALL_DIR/php-fpm/multiphp.tpl"  ${WEBTPL}/php-fpm/PHP-${php_ver/\./_}.tpl
+    done
+
+    if [ "$WEB_SYSTEM" = 'nginx' ] ]; then
+        cp -rf "${HESTIA_INSTALL_DIR}/templates/web/nginx" "${WEBTPL}/"
+    fi
+
+    # Migrate domains
+    for user in $($BIN/v-list-sys-users plain); do
+        echo "Migrating legacy multiphp domains for user: $user"
+        for domain in $($BIN/v-list-web-domains $user plain |cut -f1); do
+            echo "Processing domain: $domain"
+            web_tpl="default"
+            backend_tpl="$DEFAULT_BTPL"
+            domain_tpl=$($BIN/v-list-web-domain $user $domain |grep "^TEMPLATE:" |awk '{print $2;}' );
+
+            if [ "$domain_tpl" = "PHP-56" ]; then
+                backend_tpl="PHP-5_6"
+            elif [ "$domain_tpl" = "PHP-70" ]; then
+                backend_tpl="PHP-7_0"
+            elif [ "$domain_tpl" = "PHP-71" ]; then
+                backend_tpl="PHP-7_1"
+            elif [ "$domain_tpl" = "PHP-72" ]; then
+                backend_tpl="PHP-7_2"
+            elif [ "$domain_tpl" = "PHP-73" ] || [ "$domain_tpl" = "default" ] || [ -z "$domain_tpl" ]; then
+                backend_tpl="PHP-7_3"
+            else
+                # Custom domain template used
+                echo "Domain is using a custom multiphp template (or non-multiphp one)"
+
+                web_tpl="$domain_tpl"
+                if [ -f "${WEBTPL}/$WEB_SYSTEM/php-fpm/$web_tpl.tpl" ]; then
+                    # php-fpm backend folder allready has a template with the same name
+                    web_tpl="custom-$domain_tpl"
+                fi
+
+                # Copy custom template to php-fpm backend folder
+                mkdir -p "$WEBTPL/$WEB_SYSTEM/php-fpm"
+                if [ -f "$WEBTPL/$WEB_SYSTEM/$domain_tpl.sh" ]; then
+                    cp "$WEBTPL/$WEB_SYSTEM/$domain_tpl.sh" "$WEBTPL/$WEB_SYSTEM/php-fpm/$web_tpl.sh"
+                fi
+                cp "$WEBTPL/$WEB_SYSTEM/$domain_tpl.tpl" "$WEBTPL/$WEB_SYSTEM/php-fpm/$web_tpl.tpl"
+                cp "$WEBTPL/$WEB_SYSTEM/$domain_tpl.stpl" "$WEBTPL/$WEB_SYSTEM/php-fpm/$web_tpl.stpl"
+
+
+                if [[ $(grep "unix:/" $WEBTPL/$WEB_SYSTEM/$domain_tpl.tpl |egrep -v "^\s*#" |tail -n1) \
+                        =~ unix:\/run\/php\/php([0-9]+\.[0-9]+)-fpm.+\.sock ]]; then
+
+                    # Found a custom template that is based on official multiphp one
+                    backend_tpl="PHP-${BASH_REMATCH[1]/\./_}"
+                    echo "Custom multiphp template ($domain_tpl) compatible with backend: $backend_tpl"
+
+                    # Remove multiphp switching script
+                    rm -f "$WEBTPL/$WEB_SYSTEM/php-fpm/$web_tpl.sh"
+
+                    # Replace hardcoded php-fpm socket path with tpl variable, ignoring commented lines
+                    sed '/^[[:space:]]*#/!s/unix:.*;/%backend_lsnr%;/g' "$WEBTPL/$WEB_SYSTEM/php-fpm/$web_tpl.tpl"
+                    sed '/^[[:space:]]*#/!s/unix:.*;/%backend_lsnr%;/g' "$WEBTPL/$WEB_SYSTEM/php-fpm/$web_tpl.stpl"
+                fi
+            fi
+
+            echo "Parsed config: oldTPL=$domain_tpl newTPL:$web_tpl newBackTPL:$backend_tpl"
+            $BIN/v-change-web-domain-tpl "$user" "$domain" "$web_tpl" "no"
+            $BIN/v-change-web-domain-backend-tpl "$user" "$domain" "$backend_tpl" "no"
+            echo -e "--done--\n"
+        done
+    done
+
+    # cleanup legacy multiphp templates
+    for php_ver in $(ls /etc/php/); do
+        [ ! -d "/etc/php/$php_ver/fpm/pool.d/" ] && continue
+        echo "Remove legacy multiphp templates for: $php_ver"
+        [ -f "$WEBTPL/$WEB_SYSTEM/PHP-${php_ver//.}.sh" ]   && rm "$WEBTPL/$WEB_SYSTEM/PHP-${php_ver//.}.sh"
+        [ -f "$WEBTPL/$WEB_SYSTEM/PHP-${php_ver//.}.tpl" ]  && rm "$WEBTPL/$WEB_SYSTEM/PHP-${php_ver//.}.tpl"
+        [ -f "$WEBTPL/$WEB_SYSTEM/PHP-${php_ver//.}.stpl" ] && rm "$WEBTPL/$WEB_SYSTEM/PHP-${php_ver//.}.stpl"
+    done
+
+    # Remove default symlinks
+    [ -f "$WEBTPL/$WEB_SYSTEM/default.sh" ]   && rm "$WEBTPL/$WEB_SYSTEM/default.sh"
+    [ -f "$WEBTPL/$WEB_SYSTEM/default.tpl" ]  && rm "$WEBTPL/$WEB_SYSTEM/default.tpl"
+    [ -f "$WEBTPL/$WEB_SYSTEM/default.stpl" ] && rm "$WEBTPL/$WEB_SYSTEM/default.stpl"
+
+
+    $BIN/v-update-web-templates 'no'
+fi

+ 6 - 1
install/upgrade/versions/latest.sh

@@ -61,4 +61,9 @@ if [ ! -z "$MAIL_SYSTEM" ]; then
     if cat /etc/exim4/exim4.conf.template | grep -q 'helo_data = mail.${sender_address_domain}'; then
         sed -i 's/helo_data = mail.${sender_address_domain}/helo_data = ${sender_address_domain}/g' /etc/exim4/exim4.conf.template
     fi
-fi
+fi
+
+# Members of admin group should be permitted to enter admin folder
+if [ -d /home/admin ]; then
+    setfacl -m "g:admin:r-x" /home/admin
+fi

+ 2 - 2
src/deb/nginx/nginx.conf

@@ -39,8 +39,8 @@ http {
     fastcgi_busy_buffers_size       256k;
     fastcgi_temp_file_write_size    256k;
     fastcgi_connect_timeout         30s;
-    fastcgi_read_timeout            300s;
-    fastcgi_send_timeout            180s;
+    fastcgi_read_timeout            600s;
+    fastcgi_send_timeout            600s;
 
     # Proxy settings
     proxy_redirect                  off;

+ 59 - 1
web/css/styles.min.css

@@ -691,7 +691,6 @@ body {
   font-size: 0.9rem;
   height: 100%;
   color: #929292;
-  letter-spacing: -0.02em;
 }
 
 .body-login, .body-reset {
@@ -1053,6 +1052,65 @@ a {
   padding-top: 0.6rem;
 }
 
+.alert {
+  border-radius: 3px;
+  box-sizing: border-box;
+  display: block;
+  font-size: 0.75rem;
+  font-weight: 500;
+  margin-top: 1rem;
+  padding: 0.7rem;
+  position: relative;
+  text-align: justify;
+}
+
+.alert i.fas {
+  border-radius: 1rem;
+  font-size: 1.4rem;
+  font-weight: 600;
+  height: 2rem;
+  left: 0.5rem;
+  line-height: 2rem;
+  position: absolute;
+  text-align: center;
+  top: 0.75rem;
+  width: 2rem;
+}
+
+.alert.alert-with-icon {
+  padding-left: 3rem;
+  min-height: 3.5rem;
+}
+.alert.alert-info {
+  color: #fff;
+  background-color: #618ecc;
+}
+.alert.alert-info i.fas {
+  color: #618ecc;
+  background-color: white;
+}
+
+.alert.alert-danger {
+  color: #fff;
+  background-color: #ec6c6c;
+}
+.alert.alert-danger i.fas {
+  color: #ec6c6c;
+  background-color: white;
+}
+
+.alert.alert-success {
+  color: #fff;
+  background-color: #5ea64c;
+}
+.alert.alert-success i.fas {
+  color: #5ea64c;
+  background-color: white;
+}
+
+form#vstobjects .alert {
+  width: 380px;
+}
 
 .l-stat {
   margin: 34px auto;

+ 72 - 0
web/edit/server/index.php

@@ -33,6 +33,48 @@ if ($v_timezone == 'EST5EDT' ) $v_timezone = 'EDT';
 if ($v_timezone == 'America/Puerto_Rico' ) $v_timezone = 'AST';
 if ($v_timezone == 'America/Halifax' ) $v_timezone = 'ADT';
 
+// List supported php versions
+exec (HESTIA_CMD."v-list-web-templates-backend json", $output, $return_var);
+$backend_templates = json_decode(implode('', $output), true);
+unset($output);
+
+$v_php_versions = [
+    'php-5.6',
+    'php-7.0',
+    'php-7.1',
+    'php-7.2',
+    'php-7.3',
+];
+sort($v_php_versions);
+
+if(empty($backend_templates))
+    $v_php_versions=[];
+
+$v_php_versions = array_map(function($php_version) use ($backend_templates, $v_php_versions) {
+    // Mark installed php versions
+
+    if(stripos($php_version,'php') !== 0)
+        return false;
+
+    $phpinfo = (object) [
+        "name" => $php_version,
+        "tpl" => strtoupper(str_replace('.', '_', $php_version)),
+        "version" => str_ireplace('php-', '', $php_version)
+    ];
+
+    if(in_array($phpinfo->tpl, $backend_templates)) {
+        $phpinfo->installed = true;
+    }
+
+    if(array_search($phpinfo->name, array_reverse($v_php_versions, true)) == array_key_last($v_php_versions)) {
+        // Prevent default php version to be removed
+        if($phpinfo->installed)
+            $phpinfo->protected = true;
+    }
+
+    return $phpinfo;
+}, $v_php_versions);
+
 // List supported languages
 exec (HESTIA_CMD."v-list-sys-languages json", $output, $return_var);
 $languages = json_decode(implode('', $output), true);
@@ -115,6 +157,36 @@ if (!empty($_POST['save'])) {
         $v_hostname = $_POST['v_hostname'];
     }
 
+    // Install/remove php versions
+    if (empty($_SESSION['error_msg'])) {
+        if(!empty($v_php_versions) && count($_POST['v_php_versions'] != count($v_php_versions))) {
+            $post_php = $_POST['v_php_versions'];
+
+            array_map(function($php_version) use ($post_php) {
+
+                if(array_key_exists($php_version->tpl, $post_php)) {
+                    if(!$php_version->installed) {
+                        exec (HESTIA_CMD . "v-add-web-php " . escapeshellarg($php_version->version), $output, $return_var);
+                        check_return_code($return_var, $output);
+                        unset($output);
+                        if(empty($_SESSION['error_msg']))
+                            $php_version->installed = true;
+                    }
+                } else {
+                    if($php_version->installed && !$php_version->protected) {
+                        exec (HESTIA_CMD . "v-delete-web-php " . escapeshellarg($php_version->version), $output, $return_var);
+                        check_return_code($return_var, $output);
+                        unset($output);
+                        if(empty($_SESSION['error_msg']))
+                            $php_version->installed = false;
+                    }
+                }
+
+                return $php_version;
+            }, $v_php_versions);
+        }
+    }
+
     // Change timezone
     if (empty($_SESSION['error_msg'])) {
         if (!empty($_POST['v_timezone'])) {

+ 4 - 0
web/inc/i18n/en.php

@@ -766,5 +766,9 @@ $LANG['en'] = array(
     'Theme' => 'Appearance',
 
     'Operating System' => 'Operating System',
+    'Please wait while php is installed or removed' => 'Installing or removing php versions will take cca 1 min for every php version which will be changed,
+    please be patient until the process is finished.',
+    'Avoid adding web domains on admin account' => 'Due to the increased access rights, we strongly advise against using the admin account for direct hosting of web domains.
+    Always use a separate unprivileged user account instead.',
     
 );

+ 24 - 0
web/templates/admin/edit_server.html

@@ -243,6 +243,30 @@
                                         </tr>
 
                                         <?php } ?>
+                                        <?php if(count($v_php_versions)): ?>
+                                        <tr>
+                                            <td class="vst-text">
+                                                <?php print __('Enabled multi PHP versions') ?>
+
+                                                <span class="alert alert-info alert-with-icon">
+                                                    <i class="fas fa-info"></i>
+                                                    <?=__('Please wait while php is installed or removed')?>
+                                                </span>
+                                            </td>
+                                        </tr>
+                                        <?php foreach($v_php_versions as $php_version): ?>
+                                        <tr>
+                                            <td class="vst-text input-label">
+                                                <input type="checkbox" size="20" class="vst-checkbox"
+                                                    <?=$php_version->installed?'checked':''; ?>
+                                                    <?=$php_version->protected?'disabled':''; ?>
+                                                    id="<?=$php_version->name?>"
+                                                    name="v_php_versions[<?=$php_version->tpl?>]">
+                                                <label for="<?=$php_version->name?>"><?=$php_version->name?></label>
+                                            </td>
+                                        </tr>
+                                        <?php endforeach; ?>
+                                        <?php endif; ?>
                                     </table>
                                 </td>
                             </tr>