Help with default PHP CLI

Hello,
This is something I have had an issue with for a while. So when a new Virtual server is create the default PHP for the CLI is 5.4. Why PHP 5.4 would be installed for any reason is a bit mystifying to me. That has not been supported for nearly 5 years.

It does not matter if you change the Virtual server template PHP options to Highest available. The PHP version used by Apache and what you have configured for bash are two separate things.

I know I can create aliases after users are already created but that is quickly becoming burdensome. Is there a configuration someplace in Virtualmin that I can set PHP 7.3 as the CLI default.

Any help would be appreciated.

What’s your Linux distro?

It sounds like PHP 5.4 has always been the default/global installation but never got upgraded.

Does the output from these commands make sense?

whereis php
php -v
php --ini

whereis php73
/usr/bin/php73 -v
/usr/bin/php73 --ini

Hi Ramin,
Sorry for the delay.

I am using Centos 7

I know where all of the files are. I was just wondering if there was a setting in Virtualmin to set the CLI of new using to a different version than 5.4 - Preferably 7.3.

Can someone please help me. I am having a hard time with this. This is causing another issue.

So i need to set up a cron job that runs under root. So of course the default PHP CLI is 5.4 is used. This is not going to work, Can some one please give me a hand with this. Any help would be appreciated.

Edit your Server Templates under PHP options. Server Templates can be applied (and the default is applied if no Server Template is specified explicitly).

Hi Joe,
That does not seem to work. This is what I did:

  1. went to Virtualmin->System Settings->Server Templates->Default Settings
  2. Edit Template section: PHP options
  3. Set Default Options: 7.3.11 (Was set to Highest Available)
  4. Saved
  5. Restarted Apache
    6.SSH into server as Virtual Server User
  6. php -v
    I get the version 5.4
    I also created a new virtual server using the default template just to see if maybe the currently configured virtual servers were not using the default template updates.
    Same result. PHP at the command line under new user is 5.4.

PHP 5.4 was the default when you installed CentOS 7. I’m thinking you installed PHP 7.3 with the intention of upgrading 5.4 and it didn’t work out that way.

From the Webmin menu for Others/PHP Configuration, what’s listed for Global PHP configuration? If you see PHP 5.4 configured with /etc/php.ini, it’s no mystery why you’re getting 5.4 ouput from php -v. But if there’s no sign of PHP 5.4 anywhere in Webmin or Virtualmin, and PHP 7.3 is global, then something is definitely off.

The short answer for getting your cron job to execute with PHP 7.3 is to use the path to its binary. Try /usr/bin/php73 if PHP 7.3 was installed from a Remi package, or /usr/bin/rh-php73 if it came from a CentOS SCL package.

Edit: I just now noticed that the Webmin/Others/PHP Configuration page is not specific about the global PHP version number. But you can deduce that the global install is 5.4 if 7.3 is listed and is not global. The non-global PHP will have an unusual path to its php.ini file. Hope that clears up any confusion.

1 Like

Hi Ramin,
5.4 is installed. So, you are saying I probably should have upgraded 5.4 to 7.3 instead of installing 7.3. It was not intentional. I definitely installed 7.3. For some reason, I was under the impression that Virtualmin needed 5.4. Is that not the case. If not, would I be safe in removing 5.4?

By the way, the full path did get the cron job working. Thank you!

1 Like

Not necessarily. For one thing, it’s clear to me now that your PHP installations are normal for a multi PHP setup and nothing actually needs to be fixed unless you have other preferences.

PHP 5.4 isn’t necessary unless your scripts need it. It’s merely the official default distributed with CentOS 7. There’s no harm in keeping it – just so you’re aware that it’s the ‘global’ installation that uses the main configuration file /etc/php.ini and the main PHP binary /usr/bin/php. So if you don’t want 5.4 be sure to upgrade it instead of removing it. If you remove it you’d be removing the main global PHP installation.

Which repository did you use to install PHP 7.3? If it came from remi-safe have a look at the configuration wizard at Remi’s site: Remi's RPM repository. Those instructions are helpful at making sense of the different ways to install PHP on CentOS. Note the two options for Type of installation

  • Default/single = the only PHP installation = global
  • Multiple versions simultaneously = extra PHP installations in addition to global

Again, there’s nothing messed up about your current PHP setup, so you could just leave things as they are if you and your scripts are satisfied.

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