changing default php CLI version on the server

8 posts / 0 new
Last post
#1 Wed, 03/13/2019 - 12:32
aozcakir

changing default php CLI version on the server

Hello,

Need help in changing default php CLI version on the server

The current php CLI version is: 5.4.16

[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

[root@de ~]#

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

[root@de ~]#

Any help would be appreciated. Best, Aslan Ozcakir

Wed, 03/13/2019 - 13:10
adamjedgar

I am on my mobile phone at present so not checking mine directly...I think it's

System Settings -> Server Templates -> Default -> Apache Website,

AJECreative is the home of $5 webhosting, $15/month VPS servers (1cpu,1gb RAM, 25GB storage)
Centos7, Debian9, or Ubuntu18LTS
Available Control Panels = Centos-Webpanel, Cyberpanel, or Virtualmin

https://ajecreative.com.au

Wed, 03/13/2019 - 13:23 (Reply to #2)
aozcakir

@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

Wed, 03/13/2019 - 17:08 (Reply to #3)
adamjedgar

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)

AJECreative is the home of $5 webhosting, $15/month VPS servers (1cpu,1gb RAM, 25GB storage)
Centos7, Debian9, or Ubuntu18LTS
Available Control Panels = Centos-Webpanel, Cyberpanel, or Virtualmin

https://ajecreative.com.au

Thu, 03/14/2019 - 13:19 (Reply to #4)
aozcakir

@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

Wed, 03/13/2019 - 13:46
adamjedgar

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.

AJECreative is the home of $5 webhosting, $15/month VPS servers (1cpu,1gb RAM, 25GB storage)
Centos7, Debian9, or Ubuntu18LTS
Available Control Panels = Centos-Webpanel, Cyberpanel, or Virtualmin

https://ajecreative.com.au

Wed, 03/13/2019 - 16:17
pagio

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?

Thu, 03/14/2019 - 13:10 (Reply to #7)
aozcakir

@pagio - this worked well. Thanks. Aslan

ASLAN OZCAKIR

Topic locked