I have Centos 7 and Virtualmin installed, with the tipycal php-fpm 5.4, 7.0, 7.1 that you can choice between the versions you prefer on every virtualhost via Virtualmin control panel, and everything works well.
But when I access to the server via SSH and check php -v
I get this:
PHP 5.4.16 (cli) (built: Oct 30 2018 19:30:51)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
How can I select another php default/base version for the shell system?
Setup Yum Repository First, you need to enable Remi and EPEL yum repositories on your system. Use the following command to install the EPEL repository on your CentOS and Red Hat 7/6 systems.
Use this command to install the EPEL yum repository on your system:
sudo yum install epel-release
And now execute one of the following commands as per your operating system version to install the Remi repository:
sudo rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
Install PHP 8 on CentOS Your system is prepared for the PHP installation from yum repositories. Use one of the following commands to install PHP 8.2 or PHP 8.3 on your system based on your requirements.
yum --enablerepo=remi-php82 install php
yum --enablerepo=remi-php83 install php
Check the installed PHP version
php -v
Example output:
PHP 8.2.x (cli) (built: Dec 17 2023 16:35:58) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.2.0, Copyright (c) Zend Technologies
Install PHP Modules You may also need to install additional PHP modules based on your application requirements. The command below will install some useful additional PHP modules.
yum --enablerepo=remi-php82 install php-xml php-soap php-xmlrpc php-mbstring php-json php-gd php-mcrypt
yum --enablerepo=remi-php83 install php-xml php-soap php-xmlrpc php-mbstring php-json php-gd php-mcrypt
The text initially informed about installing PHP 7.4, 7.3, and 7.2, but now it has been updated to PHP 8.2 and 8.3.