Adding other PHP versions to the already installed HestiaCP

Hello,
I have HestiaCP installed on Debian 12, but my panel only has php 8.2.
I’d like to release 7.1 / 7.2 / 7.4 / 8.1 / 8.3
How would I do that, can someone help me please?

https://hestia.example.com:2083/edit/server/ Replace domain and Port

Installing PHP 8.4 - Community Support - Hestia Control Panel - Discourse

Check here or refer to the following document to add,

1. Introduction

This guide aims to assist users in installing and configuring PHP 8.4 on HestiaCP (Hestia Control Panel).

Note: Although the guide focuses on PHP 8.4, the same steps can be adapted for installing PHP 8.3.

2. Installing PHP 8.4

Since PHP 8.4 is now available in the Sury repository, you can install it through HestiaCP’s web UI or via the command line. Here are detailed instructions for both methods:

Installing via Web UI:

  1. Log in to HestiaCP.
  2. Navigate to the Management Settings section.
  3. Select PHP 8.4 for installation.

Installing via Command Line:

  1. Log in to your server as root.
  2. Run the following command to install PHP 8.4 (replace 8.4 with 8.3 if installing PHP 8.3):
v-add-web-php 8.4  

3. Configuring HestiaCP to Recognize PHP 8.4

After installing PHP 8.4, you may need to update HestiaCP’s configuration files to recognize the new version. Follow these necessary steps:

  1. Edit the Upgrade Configuration File:

Open the /usr/local/hestia/install/upgrade/upgrade.conf file and add 8.4 to the multiphp_v array.

multiphp_v=("5.6" "7.0" "7.1" "7.2" "7.3" "7.4" "8.0" "8.1" "8.2" "8.3" "8.4")
  1. Edit the Web Server Configuration File:

Open the /usr/local/hestia/web/edit/server/index.php file and add "php-8.4" to the $v_php_versions array.

$v_php_versions = [
    "php-5.6",
    "php-7.0",
    "php-7.1",
    "php-7.2",
    "php-7.3",
    "php-7.4",
    "php-8.0",
    "php-8.1",
    "php-8.2",
    "php-8.3",
    "php-8.4",
];
  1. Edit the CLI Command File:

Open the /usr/local/hestia/bin/v-run-cli-cmd file and add php8.4 to the appropriate conditional statements.

basecmd="$(basename "$clicmd")"
if [ "$basecmd" != 'ps' -a \
"$basecmd" != 'ls' -a \
"$basecmd" != 'tar' -a \
"$basecmd" != 'zip' -a \
"$basecmd" != 'unzip' -a \
"$basecmd" != 'gzip' -a \
"$basecmd" != 'gunzip' -a \
"$basecmd" != 'mkdir' -a \
"$basecmd" != 'find' -a \
"$basecmd" != 'id' -a \
"$basecmd" != 'grep' -a \
"$basecmd" != 'egrep' -a \
"$basecmd" != 'sed' -a \
"$basecmd" != 'cat' -a \
"$basecmd" != 'php5.6' -a \
"$basecmd" != 'php7.0' -a \
"$basecmd" != 'php7.1' -a \
"$basecmd" != 'php7.2' -a \
"$basecmd" != 'php7.3' -a \
"$basecmd" != 'php7.4' -a \
"$basecmd" != 'php8.0' -a \
"$basecmd" != 'php8.1' -a \
"$basecmd" != 'php8.2' -a \
"$basecmd" != 'php8.3' -a \
"$basecmd" != 'php8.4' -a \
"$basecmd" != 'php' -a \
"$basecmd" != "wp" -a \
"$basecmd" != 'composer' ]; then
check_result "$E_FORBIDEN" "Error: Cli command not enabled"
fi

Note: The exact addition may vary based on the existing conditions; ensure php8.4 is included where relevant.

  1. Edit the Service Restart File:

Open the /usr/local/hestia/bin/v-restart-service file and add php8.4-fpm to the relevant conditional statements.

for service in $service_list; do
if [ "$service" = "iptables" ]; then
  # Run the restart rules for iptables firewall
  $BIN/v-stop-firewall
  $BIN/v-update-firewall
elif [ "$restart" = "ssl" ] && [ "$service" = "nginx" ]; then
  service $service upgrade >> $log 2>&1
elif [ -z "$restart" -o "$restart" = "no" ] && [ \
  "$service" = "nginx" -o \
  "$service" = "apache2" -o \
  "$service" = "exim4" -o \
  "$service" = "dovecot" -o \
  "$service" = "bind9" -o \
  "$service" = "named" -o \
  "$service" = "vsftpd" -o \
  "$service" = "php5.6-fpm" -o \
  "$service" = "php7.0-fpm" -o \
  "$service" = "php7.1-fpm" -o \
  "$service" = "php7.2-fpm" -o \
  "$service" = "php7.3-fpm" -o \
  "$service" = "php7.4-fpm" -o \
  "$service" = "php8.0-fpm" -o \
  "$service" = "php8.1-fpm" -o \
  "$service" = "php8.2-fpm" -o \
  "$service" = "php8.3-fpm" -o \
  "$service" = "php8.4-fpm" -o \
  "$service" = "proftpd" -o \
  "$service" = "ssh" -o \
  "$service" = "fail2ban" ]; then
  systemctl reload-or-restart "$service" >> $log 2>&1
else
  systemctl reset-failed "$service" >> $log 2>&1
  systemctl restart "$service" >> $log 2>&1
fi

4. Verifying and Setting the Default PHP Version

After installation and configuration, verify that PHP 8.4 has been successfully installed and set it as the default version if needed.

  1. Verify PHP Version:

Run the following command to check the current PHP version:

php -v
  1. Set Default PHP Version:

If PHP 8.4 is not the default version and you wish to set it as the default, use the following command:

v-change-sys-php 8.4

5. Notes

  • Before making any configuration changes, ensure you have backed up relevant files in case you need to restore them.