Multiphp ---> php 7.4 after php 8.0 is installed

Hello,

It appears that I am missing something I need to execute.

I had php 8.0 installed in the new 1.5.2 hestia installation. Later i found some scripts need php 7.4.

I activated in system—>web—>configure php 7.4.
After rebooting, I changed the php-fpm template to 7.4. for that particular user account.

On cli with logged in as the user account (who needs php 7.4), php -v shows 8.0.

Thereafter, I installed manually v-add-web-php 7.4 and rebooted the system.

After the reboot, php -v shows further 8.0 under that user. The php scripts require 7.4 and composer fails to install the project.

Is there something else I need to take care of or is this not possible to have different php versions under different accounts?

  1. For the CLI: (Cronjob won’t work) Under user settings:
  2. For cronjobs or ssh you can use /usr/bin/phpx.x
[email protected]:~# /usr/bin/php7.4 -v
PHP 7.4.27 (cli) (built: Dec 20 2021 21:30:45) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.27, Copyright (c), by Zend Technologies
[email protected]:~# 

  1. Server wide only:
sudo update-alternatives --set php /usr/bin/php8.0
sudo update-alternatives --set phar /usr/bin/phar8.0
sudo update-alternatives --set phar.phar /usr/bin/phar.phar8.0

Hello Eris,

Thankyou for fast response.

I used the option 1. above (PHP CLI Version ) and changed 8.0—>7.4.

Under CLI, php -v shows 8.0 further.

I have executed v-rebuild-user.
No change.
Rebooted. no change.

What I want:

User1: —> php 8.0
User2: —> php 8.0
User3: —> php 8.0
User4: —> php 7.4

Currently, it shows:

User4: —> php 8.0

In above, I logged in the User4 account and have changed the CLI, as you suggested.

Overview:

  • /usr/bin/php7.4 -v shows —> 7.4 and php 7.4 is installed manually as mentioned above.
  • Account user config for PHP CLI is 7.4
  • php-fpm template for the user4 is 7_4
  • v-rebuild-user executed. No change.
    -Rebooted multiple times. No change.

Is there something I am still missing?
Or multiple php versions of 7.4 (User4) as well as 8.0 (User1-3) under different user accounts are not possible?

You need to login and logout again after you changed it.

We alter the .bash_alias file:

I have no idea why it doesn’t work.

In .bashrc there code below should be included and your client need to read .bashrc file…

# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.

if [ -f ~/.bash_aliases ]; then
    . ~/.bash_aliases
fi

Hi Eris,

Thanks for the above hint. Now it works and cli shows the env correct.

As mentioned in my above description, I had simply added php 7.4 in the system. therefore, bash_alias was missing. It gets created by the command in the last step.

The last step in my above steps was missing after executing v-add-web-php 7.4. For others, who want to follow the process I did above, you have to execute the last step as follows:

v-change-user-php-cli user 7.4

Theafter it will work.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.