From e8c912513d89d426691e40c3d79d39db834f0be9 Mon Sep 17 00:00:00 2001
From: myvesta <38690722+myvesta@users.noreply.github.com>
Date: Fri, 15 Nov 2024 16:19:52 +0100
Subject: [PATCH] Support for PHP 8.4
---
.../tools/apache-fpm-tpl/PHP-FPM-84-public.sh | 133 ++++++++++++++++++
.../apache-fpm-tpl/PHP-FPM-84-public.stpl | 36 +++++
.../apache-fpm-tpl/PHP-FPM-84-public.tpl | 30 ++++
.../tools/apache-fpm-tpl/PHP-FPM-84.sh | 133 ++++++++++++++++++
.../tools/apache-fpm-tpl/PHP-FPM-84.stpl | 36 +++++
.../tools/apache-fpm-tpl/PHP-FPM-84.tpl | 30 ++++
.../for-download/tools/multi-php-install.sh | 35 ++++-
7 files changed, 432 insertions(+), 1 deletion(-)
create mode 100644 src/deb/for-download/tools/apache-fpm-tpl/PHP-FPM-84-public.sh
create mode 100644 src/deb/for-download/tools/apache-fpm-tpl/PHP-FPM-84-public.stpl
create mode 100644 src/deb/for-download/tools/apache-fpm-tpl/PHP-FPM-84-public.tpl
create mode 100644 src/deb/for-download/tools/apache-fpm-tpl/PHP-FPM-84.sh
create mode 100644 src/deb/for-download/tools/apache-fpm-tpl/PHP-FPM-84.stpl
create mode 100644 src/deb/for-download/tools/apache-fpm-tpl/PHP-FPM-84.tpl
diff --git a/src/deb/for-download/tools/apache-fpm-tpl/PHP-FPM-84-public.sh b/src/deb/for-download/tools/apache-fpm-tpl/PHP-FPM-84-public.sh
new file mode 100644
index 000000000..cbea2de96
--- /dev/null
+++ b/src/deb/for-download/tools/apache-fpm-tpl/PHP-FPM-84-public.sh
@@ -0,0 +1,133 @@
+#!/bin/bash
+# Adding php pool conf
+user="$1"
+domain="$2"
+ip="$3"
+home_dir="$4"
+docroot="$5"
+
+pool_conf="[$2]
+
+listen = /run/php/php8.4-fpm-$2.sock
+listen.owner = $1
+listen.group = $1
+listen.mode = 0666
+
+user = $1
+group = $1
+
+pm = ondemand
+pm.max_children = 8
+request_terminate_timeout = 360s
+pm.max_requests = 4000
+pm.process_idle_timeout = 10s
+pm.status_path = /status
+
+php_admin_value[upload_tmp_dir] = /home/$1/tmp
+php_admin_value[session.save_path] = /home/$1/tmp
+php_admin_value[open_basedir] = $5:/home/$1/tmp:/bin:/usr/bin:/usr/local/bin:/var/www/html:/tmp:/usr/share:/etc/phpmyadmin:/var/lib/phpmyadmin:/etc/roundcube:/var/log/roundcube:/var/lib/roundcube
+php_admin_value[upload_max_filesize] = 800M
+php_admin_value[max_execution_time] = 300
+php_admin_value[post_max_size] = 800M
+php_admin_value[memory_limit] = 512M
+php_admin_value[sendmail_path] = \"/usr/sbin/sendmail -t -i -f info@$2\"
+php_admin_flag[mysql.allow_persistent] = off
+php_admin_flag[safe_mode] = off
+
+env[PATH] = /usr/local/bin:/usr/bin:/bin
+env[TMP] = /home/$1/tmp
+env[TMPDIR] = /home/$1/tmp
+env[TEMP] = /home/$1/tmp
+"
+
+pool_file_56="/etc/php/5.6/fpm/pool.d/$2.conf"
+pool_file_70="/etc/php/7.0/fpm/pool.d/$2.conf"
+pool_file_71="/etc/php/7.1/fpm/pool.d/$2.conf"
+pool_file_72="/etc/php/7.2/fpm/pool.d/$2.conf"
+pool_file_73="/etc/php/7.3/fpm/pool.d/$2.conf"
+pool_file_74="/etc/php/7.4/fpm/pool.d/$2.conf"
+pool_file_80="/etc/php/8.0/fpm/pool.d/$2.conf"
+pool_file_81="/etc/php/8.1/fpm/pool.d/$2.conf"
+pool_file_82="/etc/php/8.2/fpm/pool.d/$2.conf"
+pool_file_83="/etc/php/8.3/fpm/pool.d/$2.conf"
+pool_file_84="/etc/php/8.4/fpm/pool.d/$2.conf"
+
+if [ -f "$pool_file_56" ]; then
+ rm $pool_file_56
+ systemctl reset-failed php5.6-fpm
+ systemctl restart php5.6-fpm
+fi
+
+if [ -f "$pool_file_70" ]; then
+ rm $pool_file_70
+ systemctl reset-failed php7.0-fpm
+ systemctl restart php7.0-fpm
+fi
+
+if [ -f "$pool_file_71" ]; then
+ rm $pool_file_71
+ systemctl reset-failed php7.1-fpm
+ systemctl restart php7.1-fpm
+fi
+
+if [ -f "$pool_file_72" ]; then
+ rm $pool_file_72
+ systemctl reset-failed php7.2-fpm
+ systemctl restart php7.2-fpm
+fi
+
+if [ -f "$pool_file_73" ]; then
+ rm $pool_file_73
+ systemctl reset-failed php7.3-fpm
+ systemctl restart php7.3-fpm
+fi
+
+if [ -f "$pool_file_74" ]; then
+ rm $pool_file_74
+ systemctl reset-failed php7.4-fpm
+ systemctl restart php7.4-fpm
+fi
+
+if [ -f "$pool_file_80" ]; then
+ rm $pool_file_80
+ systemctl reset-failed php8.0-fpm
+ systemctl restart php8.0-fpm
+fi
+
+if [ -f "$pool_file_81" ]; then
+ rm $pool_file_81
+ systemctl reset-failed php8.1-fpm
+ systemctl restart php8.1-fpm
+fi
+
+if [ -f "$pool_file_82" ]; then
+ rm $pool_file_82
+ systemctl reset-failed php8.2-fpm
+ systemctl restart php8.2-fpm
+fi
+
+if [ -f "$pool_file_83" ]; then
+ rm $pool_file_83
+ systemctl reset-failed php8.3-fpm
+ systemctl restart php8.3-fpm
+fi
+
+write_file=0
+if [ ! -f "$pool_file_84" ]; then
+ write_file=1
+else
+ user_count=$(grep -c "/home/$1/" $pool_file_84)
+ if [ $user_count -eq 0 ]; then
+ write_file=1
+ fi
+fi
+if [ $write_file -eq 1 ]; then
+ echo "$pool_conf" > $pool_file_84
+ systemctl reset-failed php8.4-fpm
+ systemctl restart php8.4-fpm
+fi
+if [ -f "/etc/php/8.4/fpm/pool.d/www.conf" ]; then
+ rm /etc/php/8.4/fpm/pool.d/www.conf
+fi
+
+exit 0
diff --git a/src/deb/for-download/tools/apache-fpm-tpl/PHP-FPM-84-public.stpl b/src/deb/for-download/tools/apache-fpm-tpl/PHP-FPM-84-public.stpl
new file mode 100644
index 000000000..91e05b17b
--- /dev/null
+++ b/src/deb/for-download/tools/apache-fpm-tpl/PHP-FPM-84-public.stpl
@@ -0,0 +1,36 @@
+
+
+ ServerName %domain_idn%
+ %alias_string%
+ ServerAdmin %email%
+ DocumentRoot %sdocroot%/public
+ 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
+
+ AllowOverride All
+
+
+ AllowOverride All
+ SSLRequireSSL
+ Options +Includes -Indexes -FollowSymLinks +SymLinksIfOwnerMatch
+
+ SSLEngine on
+ SSLVerifyClient none
+ SSLCertificateFile %ssl_crt%
+ SSLCertificateKeyFile %ssl_key%
+ %ssl_ca_str%SSLCertificateChainFile %ssl_ca%
+
+
+ SetHandler "proxy:unix:/run/php/php8.4-fpm-%domain%.sock|fcgi://localhost/"
+
+ SetEnvIf Authorization .+ HTTP_AUTHORIZATION=$0
+
+ IncludeOptional %home%/%user%/conf/web/s%web_system%.%domain%.conf*
+
+
+
diff --git a/src/deb/for-download/tools/apache-fpm-tpl/PHP-FPM-84-public.tpl b/src/deb/for-download/tools/apache-fpm-tpl/PHP-FPM-84-public.tpl
new file mode 100644
index 000000000..94acbf15b
--- /dev/null
+++ b/src/deb/for-download/tools/apache-fpm-tpl/PHP-FPM-84-public.tpl
@@ -0,0 +1,30 @@
+
+
+ ServerName %domain_idn%
+ %alias_string%
+ ServerAdmin %email%
+ DocumentRoot %docroot%/public
+ 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
+
+ AllowOverride All
+
+
+ AllowOverride All
+ Options +Includes -Indexes -FollowSymLinks +SymLinksIfOwnerMatch
+
+
+
+ SetHandler "proxy:unix:/run/php/php8.4-fpm-%domain%.sock|fcgi://localhost/"
+
+ SetEnvIf Authorization .+ HTTP_AUTHORIZATION=$0
+
+ IncludeOptional %home%/%user%/conf/web/%web_system%.%domain%.conf*
+
+
+
diff --git a/src/deb/for-download/tools/apache-fpm-tpl/PHP-FPM-84.sh b/src/deb/for-download/tools/apache-fpm-tpl/PHP-FPM-84.sh
new file mode 100644
index 000000000..cbea2de96
--- /dev/null
+++ b/src/deb/for-download/tools/apache-fpm-tpl/PHP-FPM-84.sh
@@ -0,0 +1,133 @@
+#!/bin/bash
+# Adding php pool conf
+user="$1"
+domain="$2"
+ip="$3"
+home_dir="$4"
+docroot="$5"
+
+pool_conf="[$2]
+
+listen = /run/php/php8.4-fpm-$2.sock
+listen.owner = $1
+listen.group = $1
+listen.mode = 0666
+
+user = $1
+group = $1
+
+pm = ondemand
+pm.max_children = 8
+request_terminate_timeout = 360s
+pm.max_requests = 4000
+pm.process_idle_timeout = 10s
+pm.status_path = /status
+
+php_admin_value[upload_tmp_dir] = /home/$1/tmp
+php_admin_value[session.save_path] = /home/$1/tmp
+php_admin_value[open_basedir] = $5:/home/$1/tmp:/bin:/usr/bin:/usr/local/bin:/var/www/html:/tmp:/usr/share:/etc/phpmyadmin:/var/lib/phpmyadmin:/etc/roundcube:/var/log/roundcube:/var/lib/roundcube
+php_admin_value[upload_max_filesize] = 800M
+php_admin_value[max_execution_time] = 300
+php_admin_value[post_max_size] = 800M
+php_admin_value[memory_limit] = 512M
+php_admin_value[sendmail_path] = \"/usr/sbin/sendmail -t -i -f info@$2\"
+php_admin_flag[mysql.allow_persistent] = off
+php_admin_flag[safe_mode] = off
+
+env[PATH] = /usr/local/bin:/usr/bin:/bin
+env[TMP] = /home/$1/tmp
+env[TMPDIR] = /home/$1/tmp
+env[TEMP] = /home/$1/tmp
+"
+
+pool_file_56="/etc/php/5.6/fpm/pool.d/$2.conf"
+pool_file_70="/etc/php/7.0/fpm/pool.d/$2.conf"
+pool_file_71="/etc/php/7.1/fpm/pool.d/$2.conf"
+pool_file_72="/etc/php/7.2/fpm/pool.d/$2.conf"
+pool_file_73="/etc/php/7.3/fpm/pool.d/$2.conf"
+pool_file_74="/etc/php/7.4/fpm/pool.d/$2.conf"
+pool_file_80="/etc/php/8.0/fpm/pool.d/$2.conf"
+pool_file_81="/etc/php/8.1/fpm/pool.d/$2.conf"
+pool_file_82="/etc/php/8.2/fpm/pool.d/$2.conf"
+pool_file_83="/etc/php/8.3/fpm/pool.d/$2.conf"
+pool_file_84="/etc/php/8.4/fpm/pool.d/$2.conf"
+
+if [ -f "$pool_file_56" ]; then
+ rm $pool_file_56
+ systemctl reset-failed php5.6-fpm
+ systemctl restart php5.6-fpm
+fi
+
+if [ -f "$pool_file_70" ]; then
+ rm $pool_file_70
+ systemctl reset-failed php7.0-fpm
+ systemctl restart php7.0-fpm
+fi
+
+if [ -f "$pool_file_71" ]; then
+ rm $pool_file_71
+ systemctl reset-failed php7.1-fpm
+ systemctl restart php7.1-fpm
+fi
+
+if [ -f "$pool_file_72" ]; then
+ rm $pool_file_72
+ systemctl reset-failed php7.2-fpm
+ systemctl restart php7.2-fpm
+fi
+
+if [ -f "$pool_file_73" ]; then
+ rm $pool_file_73
+ systemctl reset-failed php7.3-fpm
+ systemctl restart php7.3-fpm
+fi
+
+if [ -f "$pool_file_74" ]; then
+ rm $pool_file_74
+ systemctl reset-failed php7.4-fpm
+ systemctl restart php7.4-fpm
+fi
+
+if [ -f "$pool_file_80" ]; then
+ rm $pool_file_80
+ systemctl reset-failed php8.0-fpm
+ systemctl restart php8.0-fpm
+fi
+
+if [ -f "$pool_file_81" ]; then
+ rm $pool_file_81
+ systemctl reset-failed php8.1-fpm
+ systemctl restart php8.1-fpm
+fi
+
+if [ -f "$pool_file_82" ]; then
+ rm $pool_file_82
+ systemctl reset-failed php8.2-fpm
+ systemctl restart php8.2-fpm
+fi
+
+if [ -f "$pool_file_83" ]; then
+ rm $pool_file_83
+ systemctl reset-failed php8.3-fpm
+ systemctl restart php8.3-fpm
+fi
+
+write_file=0
+if [ ! -f "$pool_file_84" ]; then
+ write_file=1
+else
+ user_count=$(grep -c "/home/$1/" $pool_file_84)
+ if [ $user_count -eq 0 ]; then
+ write_file=1
+ fi
+fi
+if [ $write_file -eq 1 ]; then
+ echo "$pool_conf" > $pool_file_84
+ systemctl reset-failed php8.4-fpm
+ systemctl restart php8.4-fpm
+fi
+if [ -f "/etc/php/8.4/fpm/pool.d/www.conf" ]; then
+ rm /etc/php/8.4/fpm/pool.d/www.conf
+fi
+
+exit 0
diff --git a/src/deb/for-download/tools/apache-fpm-tpl/PHP-FPM-84.stpl b/src/deb/for-download/tools/apache-fpm-tpl/PHP-FPM-84.stpl
new file mode 100644
index 000000000..848abf7cd
--- /dev/null
+++ b/src/deb/for-download/tools/apache-fpm-tpl/PHP-FPM-84.stpl
@@ -0,0 +1,36 @@
+
+
+ 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
+
+ AllowOverride All
+
+
+ AllowOverride All
+ SSLRequireSSL
+ Options +Includes -Indexes -FollowSymLinks +SymLinksIfOwnerMatch
+
+ SSLEngine on
+ SSLVerifyClient none
+ SSLCertificateFile %ssl_crt%
+ SSLCertificateKeyFile %ssl_key%
+ %ssl_ca_str%SSLCertificateChainFile %ssl_ca%
+
+
+ SetHandler "proxy:unix:/run/php/php8.4-fpm-%domain%.sock|fcgi://localhost/"
+
+ SetEnvIf Authorization .+ HTTP_AUTHORIZATION=$0
+
+ IncludeOptional %home%/%user%/conf/web/s%web_system%.%domain%.conf*
+
+
+
diff --git a/src/deb/for-download/tools/apache-fpm-tpl/PHP-FPM-84.tpl b/src/deb/for-download/tools/apache-fpm-tpl/PHP-FPM-84.tpl
new file mode 100644
index 000000000..065c1f89c
--- /dev/null
+++ b/src/deb/for-download/tools/apache-fpm-tpl/PHP-FPM-84.tpl
@@ -0,0 +1,30 @@
+
+
+ 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
+
+ AllowOverride All
+
+
+ AllowOverride All
+ Options +Includes -Indexes -FollowSymLinks +SymLinksIfOwnerMatch
+
+
+
+ SetHandler "proxy:unix:/run/php/php8.4-fpm-%domain%.sock|fcgi://localhost/"
+
+ SetEnvIf Authorization .+ HTTP_AUTHORIZATION=$0
+
+ IncludeOptional %home%/%user%/conf/web/%web_system%.%domain%.conf*
+
+
+
diff --git a/src/deb/for-download/tools/multi-php-install.sh b/src/deb/for-download/tools/multi-php-install.sh
index 6a65a8888..cc0242027 100644
--- a/src/deb/for-download/tools/multi-php-install.sh
+++ b/src/deb/for-download/tools/multi-php-install.sh
@@ -14,6 +14,7 @@ inst_80=0
inst_81=0
inst_82=0
inst_83=0
+inst_84=0
#######################################################################
@@ -60,8 +61,11 @@ fi
if [ $# -gt 10 ]; then
inst_83=${11}
fi
+if [ $# -gt 11 ]; then
+ inst_84=${12}
+fi
-if [ $inst_56 -eq 1 ] || [ $inst_70 -eq 1 ] || [ $inst_71 -eq 1 ] || [ $inst_72 -eq 1 ] || [ $inst_73 -eq 1 ] || [ $inst_74 -eq 1 ] || [ $inst_80 -eq 1 ] || [ $inst_81 -eq 1 ] || [ $inst_82 -eq 1 ] || [ $inst_83 -eq 1 ]; then
+if [ $inst_56 -eq 1 ] || [ $inst_70 -eq 1 ] || [ $inst_71 -eq 1 ] || [ $inst_72 -eq 1 ] || [ $inst_73 -eq 1 ] || [ $inst_74 -eq 1 ] || [ $inst_80 -eq 1 ] || [ $inst_81 -eq 1 ] || [ $inst_82 -eq 1 ] || [ $inst_83 -eq 1 ] || [ $inst_84 -eq 1 ]; then
inst_repo=1
fi
@@ -92,6 +96,7 @@ echo "inst_80=$inst_80"
echo "inst_81=$inst_81"
echo "inst_82=$inst_82"
echo "inst_83=$inst_83"
+echo "inst_84=$inst_84"
echo "wait_to_press_enter=$wait_to_press_enter"
press_enter "=== Press enter to continue ==============================================================================="
@@ -372,6 +377,33 @@ if [ "$inst_83" -eq 1 ]; then
press_enter "=== PHP 8.3 installed, press enter to continue ==============================================================================="
fi
+if [ "$inst_84" -eq 1 ]; then
+ press_enter "=== Press enter to install PHP 8.4 ==============================================================================="
+ apt -y install php8.4-mbstring php8.4-bcmath php8.4-cli php8.4-curl php8.4-fpm php8.4-gd php8.4-intl php8.4-mysql php8.4-soap php8.4-xml php8.4-zip php8.4-memcache php8.4-memcached php8.4-imagick
+ update-rc.d php8.4-fpm defaults
+ a2enconf php8.4-fpm
+ a2dismod php8.4
+ apt-get -y remove libapache2-mod-php8.4
+ systemctl restart apache2
+ cp -r /etc/php/8.4/ /root/vst_install_backups/php8.4/
+ wget -nv https://c.myvestacp.com/tools/apache-fpm-tpl/PHP-FPM-84.stpl -O /usr/local/vesta/data/templates/web/apache2/PHP-FPM-84.stpl
+ wget -nv https://c.myvestacp.com/tools/apache-fpm-tpl/PHP-FPM-84.tpl -O /usr/local/vesta/data/templates/web/apache2/PHP-FPM-84.tpl
+ wget -nv https://c.myvestacp.com/tools/apache-fpm-tpl/PHP-FPM-84.sh -O /usr/local/vesta/data/templates/web/apache2/PHP-FPM-84.sh
+ wget -nv https://c.myvestacp.com/tools/apache-fpm-tpl/PHP-FPM-84-public.stpl -O /usr/local/vesta/data/templates/web/apache2/PHP-FPM-84-public.stpl
+ wget -nv https://c.myvestacp.com/tools/apache-fpm-tpl/PHP-FPM-84-public.tpl -O /usr/local/vesta/data/templates/web/apache2/PHP-FPM-84-public.tpl
+ wget -nv https://c.myvestacp.com/tools/apache-fpm-tpl/PHP-FPM-84-public.sh -O /usr/local/vesta/data/templates/web/apache2/PHP-FPM-84-public.sh
+ chmod a+x /usr/local/vesta/data/templates/web/apache2/PHP-FPM-84.sh
+ chmod a+x /usr/local/vesta/data/templates/web/apache2/PHP-FPM-84-public.sh
+ echo "=== Patching php.ini for php8.4"
+ wget -nv https://c.myvestacp.com/tools/patches/php8.2.patch -O /root/php8.4.patch
+ patch /etc/php/8.4/fpm/php.ini < /root/php8.4.patch
+ if [ $memory -gt 9999999 ]; then
+ sed -i "s|opcache.memory_consumption=512|opcache.memory_consumption=2048|g" /etc/php/8.4/fpm/php.ini
+ fi
+ service php8.4-fpm restart
+ press_enter "=== PHP 8.4 installed, press enter to continue ==============================================================================="
+fi
+
apt update > /dev/null 2>&1
apt upgrade -y > /dev/null 2>&1
@@ -389,6 +421,7 @@ if [ $debian_version -ge 10 ]; then
a2dismod php8.1 > /dev/null 2>&1
a2dismod php8.2 > /dev/null 2>&1
a2dismod php8.3 > /dev/null 2>&1
+ a2dismod php8.4 > /dev/null 2>&1
a2dismod mpm_prefork > /dev/null 2>&1
a2enmod mpm_event > /dev/null 2>&1
apt-get -y remove libapache2-mod-php* > /dev/null 2>&1