These forums are locked and archived, but all topics have been migrated to the new forum. You can search for this topic on the new forum: Search for changing default php CLI version on the server on the new forum.
Hello,
Need help in changing default php CLI version on the server
[root@de ~]# php -v 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
I need to change the default php CLI to php 7.0 which already installed on the server. Do you happen to know how to do this?
[root@de ~]# virtualmin list-php-versions Version Path
5 /bin/php-cgi 7.0 /opt/rh/rh-php70/root/usr/bin/php-cgi 5.4
Any help would be appreciated. Best, Aslan Ozcakir
I am on my mobile phone at present so not checking mine directly...I think it's
System Settings -> Server Templates -> Default -> Apache Website,
https://ajecreative.com.au
@adamjedgar thanks for the prompt reply / comment. The System Settings -> Server Templates -> Default -> PHP Options is to set the default for virtual servers FastCGI. I would like to set the CLI default to PHP 7.0 When I connect with SSH and type php -v I need the server to show me php 7.0.27 instead ot php 5.4.26 Anyway thanks again for the effort. Aslan
ASLAN OZCAKIR
What is showing when you go into webmin>others>php configuration? mine is as follows
Configuration file Purpose Actions
/etc/php/7.0/cgi/php.ini PHP 7.0
/etc/php/7.1/cgi/php.ini PHP 7.1
/etc/php/7.2/cgi/php.ini PHP 7.2
/etc/php/7.3/cgi/php.ini PHP 7.3
have you set your default php version to the "highest available" in system settings>server templates>default>php options
Also, are you actually using the "default" template on your virtual server?
You may not be using the default template, therefore you would need to also choose system settings>server templates> "your current virtual server template">php options
when you say, "when i connect with ssh", what returns if you just use the built in virtualmin terminal window ( ie >_ ) and type php -v? (my assumption is that it would be same as ssh)
For one of my virtualmin>virtual servers, in terminal window, I get (i have other php versions on the webmin system but not all are automatically available to every virtual serer...it depends on what i want to make available for a particular server template.)
# php -v
PHP 7.3.3-1+0~20190307202245.32+stretch~1.gbp32ebb2 (cli) (built: Mar 7 2019 20:22:46) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.3, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.3.3-1+0~20190307202245.32+stretch~1.gbp32ebb2, Copyright (c) 1999-2018, by Zend Technologie
i added the ondrej repository to virtualmin (not sure if that is still what we need to do now or not)
add-apt-repository ppa:ondrej/php
apt update
Then you need to configure virtualmin to use specific php version virtualmin>virtual server>server configuration>php version
After this then go back into Virtualmin>system settings>your server template (ie default or whatever you are using for current virtual server)>php options and choose php 7.0.30 (or "highest available")
For example, if your highest available is version php 7.1, you can also set say php 7.1 from command line by doing the following...
update-alternatives --list php
update-alternatives --set php /usr/bin/php 7.1 (your path here might be different...so check what the php path needs to be first (perhaps in file manager)
https://ajecreative.com.au
@adamjedgar: Thanks a lot for the detailed explanation and instructions. I could not "Configuration file Purpose Actions" figure out this. For the rest: "have you set your default php version to the "highest available" in system settings>server templates>default>php options" YES, please see the screenshot from: https://www.dropbox.com/s/35g56650lzvg5ez/PHP-OPTIONS.png?dl=0
"You may not be using the default template, therefore you would need to also choose system settings>server templates> "your current virtual server template">php options" YES, please see the screenshot from: https://www.dropbox.com/s/7jt4vhbm0krhek3/VIRTUAL-SERVER.png?dl=0
I am sorry but I am lost at this point.
But nevertheless I have solved the issue with the help of @pagio as follows:You can add an alias for the You can add an alias for the current user by editing ~/.bashrc and adding the following:
alias php='/opt/rh/rh-php70/root/usr/bin/php'ASLAN OZCAKIR
I will take a look at my server when I get up in a few hours time and see what I can find.
It's still nighttime here... very early in the morning.
https://ajecreative.com.au
You can add an alias for the current user by editing ~/.bashrc and adding the following:
alias php='/opt/rh/rh-php70/root/usr/bin/php'
It works?
@pagio - this worked well. Thanks. Aslan
ASLAN OZCAKIR