How do I replace php 5.4 with 5.6 as base PHP?

Hi

I have installed 5.6 using the guide here. https://www.virtualmin.com/documentation/web/multiplephp#toc-installing-... Then I have tried to run the replace command. yum replace php-common --replace-with=rh-php56-php-common

But when I try to run php -v it doesn't get the command. When trying to restart the httpd service it can't locate the php process

What do I miss here? I am running Centos 7.

PS. To get the yum-replace-plugin installed I followed the following. To use the IUS packages in CentOS 7:

  1. Install EPEL and IUS repositories:
yum --enablerepo=extras install epel-release yum install https://centos7.iuscommunity.org/ius-release.rpm
  1. Install yum-plugin-replace and replace the php packages with php56u packages:
yum install yum-plugin-replace yum replace --replace-with php56u php
  1. Restart any services which depend on php, such as httpd.
  • Tim

Comments

Howdy -- the instructions on the Virtualmin site are for installing a second PHP version side-by-side with your existing PHP version.

In that case, you don't need to remove or replace anything.

You would then have a second PHP version, which should be detected when going into System Settings -> Re-Check Config. You would have a new PHP binary you could call when you need access to the other PHP version.

Hi

Thanks, I am aware, but I want to replace the core PHP with the new PHP 5.6 repo, is that possible?

  • Tim

Hi Mostafa

Did the above, php 5.6.29 is installed and ioncube 5.6 is enabled. Apache seems not to use the PHP though, when I open a webpage it downloads the index file. So what settings are I missing to be able to compile the PHP files?

  • Tim
Mostafa's picture
Submitted by Mostafa on Wed, 01/11/2017 - 13:23

To fix the download issue, open the file /etc/httpd/conf.d/php.conf and comment out SetHandler application/x-httpd-php and restart apache

You should also run Recheck-Configuration in virtualmin and make sure that everything is fine there.

Hi Mostafa

All looks fine when running the "recheck-configuration". I will try to add the sethandler and get back to you.

  • Tim

Hi

It's already commented out in the php.conf file.

  • Tim

Here is the result of the recheck configuration. The following PHP versions are available : 5.6.29 (/bin/php-cgi)

  • Tim

I just want to clarify, we don't recommend using third party repositories for what you're describing, as we've seen a number of issues with that.

Mostafa's advice is how some folks accomplish that, though we've seen problems with packages from repositories such as that one which cause problems during some updates.

So if you want to use a repository other than the SCL repo, you can do that, but we recommend caution when doing so... and if you can make snapshots of your server (ie, if it's a VPS), we'd recommend that :-)

So if I use the SCL repo for the replacement of the PHP version 5.4 it would work?

  • Tim

I just want to replace the base PHP 5.4 with 5.6.x to be able to get WHMCS version 7.x working correctly.

The problem is that the base system PHP is still 5.4 even though I install the 5.6 version from the SCL repo. That gives me some problems running CRON jobs in WHMCS.

  • Tim

We don't recommend replacing PHP, and the SCL is not designed to do that.

What we suggest doing is installing a second PHP version, and have WHMCS use that second PHP version.

It sounds like in your case, that your cron jobs aren't using the second PHP version, and that is fixable.

You'd either want to not call PHP scripts directly from cron -- instead, call them via Apache with something like:

@daily wget mydomain.com/whmcs/admin/cron.php

Or, if you have a script that's being run like this:

php -q /home/domain/public_html/whmcs/admin/cron.php

Modify the command line to use your preferred PHP version, something like:

/path/to/php56 -q /home/domain/public_html/whmcs/admin/cron.php
Mostafa's picture
Submitted by Mostafa on Thu, 01/12/2017 - 01:05

@andreycheck Remi repo also supports multiphp the same way as SCL does

I remember that I had that download issue once when upgraded the base php packages however I could manage to fix it, and iirc it has something to do with php.conf file. wish we could find the reason this time and add it to the documentation for future references. This is actually one important feature that I LOVE about Virtualmin (and you don't find it on other panels e.g. cpanel, directadmin, plesk, ...) that Virtualmin manages what you have on your system, and you are not limited to just use a particular repository.

Hi both

I already have the second PHP version 5.6 running. My basic question was if it was possible to replace the PHP base version, the 5.4 is quite old already.

I have managed to fix the WHMCS issue using the multiple PHP installation.

  • Tim

There isn't a Virtualmin-supported way to do that unfortunately.

There are ways to accomplish it, such as using third party repositories -- but we would recommend either using two PHP versions, or upgrading your distro to a more recent distro.

Hi Eric

Thanks for your answer. I will leave it here until a newer version, hopefully, soon will be out on the officiel channels.

  • Tim
Status: Active ยป Closed (fixed)