• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

Question Change php version on terminal

Stergios G

Basic Pleskian
Server operating system version
AlmaLinux 8.7
Plesk version and microupdate number
18.0.49
Ι am try to install Magento 2.4 on a new Plesk subscription. Magento 2.4 need php7.4 or higher for installation.
Plesk subscription is set to php7,4.

But i get the error: Magento supports PHP 7.4.0 or later. Please read Magento System Requirements.

I soon understood (In terminal) that the php version is 7.3.

Code:
[root@hs23 ~]# php --version
PHP 7.3.33 (cli) (built: Dec 19 2022 14:14:16) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.33, Copyright (c) 1998-2018 Zend Technologies
    with the ionCube PHP Loader + ionCube24 v12.0.5, Copyright (c) 2002-2022, by ionCube Ltd.
    with Zend OPcache v7.3.33, Copyright (c) 1999-2018, by Zend Technologies

On php modules list i have those results:

Code:
[root@hs23 ~]# sudo dnf module list php
Last metadata expiration check: 3:34:33 ago on Wed 25 Jan 2023 11:49:11 AM EET.
AlmaLinux 8 - AppStream
Name     Stream      Profiles                      Summary                 
php      7.2 [d]     common [d], devel, minimal    PHP scripting language   
php      7.3         common [d], devel, minimal    PHP scripting language   
php      7.4         common [d], devel, minimal    PHP scripting language   
php      8.0         common [d], devel, minimal    PHP scripting language   

Remi's Modular repository for Enterprise Linux 8 - x86_64
Name     Stream      Profiles                      Summary                 
php     remi-7.2       common [d], devel, minimal   PHP scripting language  
php     remi-7.3       common [d], devel, minimal   PHP scripting language  
php     remi-7.4       common [d], devel, minimal   PHP scripting language  
php     remi-8.0 [e]   common [d], devel, minimal   PHP scripting language  
php     remi-8.1       common [d], devel, minimal   PHP scripting language  
php     remi-8.2       common [d], devel, minimal   PHP scripting language 
Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled

An i wonder...
why on php --version i have php7.3.33, on php module list: default php7.2 and how can i change php version on 7.4?

ok for the first two i have a theory, but how to toggle between php versions?
 
Instead of using PHP command in the command line use /opt/plesk/php/7.4/bin/php to run PHP version 7.4 (if installed on you're server). Change the version in the command according to your need.

The PHP command runs the default PHP version that ships with your OS.
 
Because I have read many post... I tried to install last PHP on AlmaLinux/Rocky from Remi Repo.
Code:
[root@hs23 ~]# sudo dnf install php -y
Last metadata expiration check: 3:50:11 ago on Wed 25 Jan 2023 11:49:11 AM EET.
Package php-7.3.33-7.el8.remi.x86_64 is already installed.
Error:
 Problem: cannot install both php-common-8.0.27-1.el8.remi.x86_64 and php-common-7.3.33-7.el8.remi.x86_64
  - package php-8.0.27-1.el8.remi.x86_64 requires php-common(x86-64) = 8.0.27-1.el8.remi, but none of the providers can be installed
  - package php-ioncube-loader-12.0.5-1.el8.remi.7.3.x86_64 requires php(api) = 20180731-64, but none of the providers can be installed
  - package php-ioncube-loader-12.0.5-1.el8.remi.7.3.x86_64 requires php(zend-abi) = 20180731-64, but none of the providers can be installed
  - cannot install the best candidate for the job
  - problem with installed package php-ioncube-loader-12.0.5-1.el8.remi.7.3.x86_64
  - package php-common-7.3.20-1.module_el8.3.0+2009+b272fdef.x86_64 is filtered out by modular filtering
  - package php-common-7.3.33-6.el8.remi.x86_64 is filtered out by modular filtering
  - package php-common-7.3.33-7.el8.remi.x86_64 is filtered out by modular filtering
(try to add '--allowerasing' to command line to replace conflicting packages or '--skip-broken' to skip uninstallable packages or '--nobest' to use not only best candidate packages)

[root@hs23 ~]# php --version
PHP 7.3.33 (cli) (built: Dec 19 2022 14:14:16) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.33, Copyright (c) 1998-2018 Zend Technologies
    with the ionCube PHP Loader + ionCube24 v12.0.5, Copyright (c) 2002-2022, by ionCube Ltd.
    with Zend OPcache v7.3.33, Copyright (c) 1999-2018, by Zend Technologies
[root@hs23 ~]#

Still php7.3.33
 
Instead of using PHP command in the command line use /opt/plesk/php/7.4/bin/php to run PHP version 7.4 (if installed on you're server). Change the version in the command according to your need.

The PHP command runs the default PHP version that ships with your OS.
Hi kaspar and thnx for reply.
Plz help me to understand. is /opt/plesk/php/7.4/bin/php a command for terminal which change php version?
Because when i type it terminal stop on cursor.
1674655533434.png
 
It's a replacement command for running a specific PHP version. So instead of running php bin/magento cache:clean you'd run /opt/plesk/php/7.4/bin/php bin/magento cache:clean for example.
 
It's a replacement command for running a specific PHP version. So instead of running php bin/magento cache:clean you'd run /opt/plesk/php/7.4/bin/php bin/magento cache:clean for example.
Thnx for your explanation, it was useful, but how to make a php 7.4 environment on terminal and run magento installation from web-brower?

Remi repository may not be the #1 choice.

Anyway, this article might help:
Peter thnx for your reply, this was the first guide I read. But i have some problems on many steps, i suppose i must fix those first.

It will be a long road..
 
Hi again.
Sorry but i can not understand.
Why i need configure a specific command line PHP version and not entire server?
Why a magento installation do not use subscription php version and extensions?
How to know if i am in chrooted or non-chrooted environment? i tried to follow "How to configure a specific command line PHP version for an SSH user on a Plesk for Linux server?" guide and i have errors on any command on terminal.

How to start the debugging? Would you like me to post all the commands and results from the guide here?
 
You need to be logged in as "root" on your server in order to being able to apply the commands from the article, because this changes the configuration of your server.
 
You need to be logged in as "root" on your server in order to being able to apply the commands from the article, because this changes the configuration of your server.
But i am root user, which of two paths i must follow? chrooted or non-chrooted?
 
That depends on what you have selected in the "Hosting Settings > Web Hosting Access > Access to the server over SSH" settings.
 
Back
Top