Using the right PHP version

Using the right PHP version

by Jerry Lau -
Number of replies: 13

Hello folks... this has got me stumped.

I have a redhat 6.6 64-bit os and upgraded my php to 5.6.25 in preparation to test moodle 3.2 

I checked my php version and it shows it as the right one. I even enabled it via " source /opt/rh/rh-php56/enable"

PHP 5.6.25 (cli) (built: Sep  6 2016 08:19:42)

However, when I go to my moodle site, it says:

Moodle 3.2 or later requires at least PHP 5.6.5 (currently using version 5.5.21). Some servers may have multiple PHP versions installed, are you using the correct executable?

How do make sure it is using the right one then? I even uninstalled the 5.5.x version.. is it a cache problem? I rebooted the server already.

So I did a test phpinfo page and it was looking at my old php version of 5.5.21


PHP Version 5.5.21

Never encountered this before...

thoughts?

Average of ratings: -
In reply to Jerry Lau

Re: Using the right PHP version

by Jerry Lau -

Nevermind... I think I found the answer

Add the LoadModule command to your httpd.conf and point it to the php56 module from RHSCL:

LoadModule php5_module /opt/rh/httpd24/root/usr/lib64/httpd/modules/librh-php56-php5.so


Average of ratings: Useful (2)
In reply to Jerry Lau

Re: Using the right PHP version

by Heiko Schach -

Will this work directly with RHEL's stock Apache, the one that has its configuration in /etc/httpd/conf/httpd.conf?
Or do I need to run RHSCL's Apache version (httpd24-* packages) installed as a dependency by rh-php56-php?

In reply to Jerry Lau

Re: Using the right PHP version

by Joe Amatrucola -

Hi

I'm struggling to figure out how to upgrade the version of PHP on my CentOS 6.8 server to 5.6.5 (the minimum specified version for Moodle 3.2).  When I upgraded to Moodle 3.0 I had to enable the remi repository on the server so I could get up to 5.4.45.  As best I can tell, even [remi-php56] is not distributing 5.6.5, as the highest I've been able to get from it is 5.6.29 (as recently as this morning, since last night it would just go up to 5.6.28).

Any suggestions about how to safely get to PHP 5.6.5 on CentOS?

Thanks!

Joe


PS: I'm inferring that Jerry Lau above may be running into a similar issue, since his post refers to getting the server up to 5.6.25 which is still below 5.6.5.  Not sure if he's using remi, however.

In reply to Joe Amatrucola

Re: Using the right PHP version

by Ken Task -
Picture of Particularly helpful Moodlers

@Joe ...

Jerry was using RHSCL (RedHat Software Collections) which is commercial (?)

https://access.redhat.com/solutions/472793

You can get higher versions of php for CentOS 6 and 7 from Webtatic.

https://webtatic.com/packages/php56/

php56w.x86_64 5.6.28-1.w6 (which is beyond what is required for Moodle).

Install the yum.repo files via the link above - note ... make sure you get the ones for CentOS/EL 6.

Also, might want to disable the repo in the webtatic repo file to prevent getting confused about other packages offered by Webtatic.   Means you will have to enable the repo to install and update/upgrade.

*Strongly suggest* you run an environment check (update the component) on your current server and check your addons for compatibility with 3.2.

https://moodle.org/plugins/?q=moodle-version:3.2

'spirit of sharing', Ken


Average of ratings: Useful (1)
In reply to Ken Task

Re: Using the right PHP version

by Joe Amatrucola -

Thanks for the information, Ken.  In all honesty, I had read about and come across the Webtatic repository, but was shying away from it due to some posts like this one I had found: "...The webtatic repo contains many packages with names that conflict with the names of packages in CentOS base and updates repos. This means that it replaces packages supplied by CentOS without warning..."  I believe this is part of the reason why you're suggesting leaving the repo disabled by default - so I only make use of it when I intend to do so.

If by "run an environment check" you are referring to this utility in Site Administration, I have done so and think I'm good there:
  /admin/environment.php?version=3.2

I'm still just experimenting with Moodle 3.2 in a testing environment at this point, and appreciate the reminder to check plugins for compatibility as well.

Many thanks!
Joe

In reply to Joe Amatrucola

Re: Using the right PHP version

by Ken Task -
Picture of Particularly helpful Moodlers

"I believe this is part of the reason why you're suggesting leaving the repo disabled by default - so I only make use of it when I intend to do so."

Yep!  100% correct.   There is also a yum-priorities one could install and then one could give the standard repos higher priority (weight) so that they are checked and used first.   Webtatic given the last number (priority).

What I've observed, however ... the system knows what repo installed what.   So as long as the only package installed via Webtatic is PHP + PHP extensions, then even a 'regular' yum update will use Webtatic ONLY for PHP + PHP extensions.

'spirit of sharing', Ken

Average of ratings: Useful (1)
In reply to Ken Task

Re: Using the right PHP version

by Joe Amatrucola -

Hi Ken

Quoting above: php56w.x86_64 5.6.28-1.w6 (which is beyond what is required for Moodle).

Is that really the case?  When I read this, I was surprised, as I presumed that this package would correspond to PHP 5.6.28, and Moodle 3.2 requires PHP 5.6.5.  But since I'm still learning, I continued to go about using the Webtatic repo to upgrade the PHP version beyond my current version of 5.6.29.  After carefully installing the yum.repo file and setting it to enabled=0, I executed:

yum install php56w --enablerepo=webtatic

and received the message:

"Package php56w-5.6.28-1.w6.x86_64 is obsoleted by php-5.6.29-1.el6.remi.x86_64 which is already installed. Nothing to do"

So, I'm back to being a bit confused again.  Here are my 2 main confusions:

  1. If Webtatic really does include a version of PHP greater than or equal to 5.6.5, I don't see how to get at it.
  2. In my testing I went ahead and installed Moodle 3.2 on the server that's running PHP 5.6.29 just to see what would happen.  During the install the environment check for php displayed "version 5.6.5 is required and you are running 5.6.29" but it had a status of OK, so I proceeded.  Moodle 3.2 installed successfully.  It's up and running, though I'll admit that I've done next to no testing.  Dare I ask if it's OK to run Moodle 3.2 on PHP 5.6.29, or is that a horrible idea?

Thanks, as always.

Joe

In reply to Joe Amatrucola

Re: Using the right PHP version

by AL Rachels -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers

5.6.five  is older than version 5.6.twentynine. It is perfectly okay to use 5.6.29

Average of ratings: Useful (2)
In reply to AL Rachels

Re: Using the right PHP version

by Mark Hayes -

Yes, the versioning is confusing.

They should probably call it 5.6.05 to make it clearer that it came before 5.6.29

Average of ratings: Useful (1)
In reply to Joe Amatrucola

Re: Using the right PHP version

by Ken Task -
Picture of Particularly helpful Moodlers

As Al has already informed ... php does it's versioning by increasing the last digits .... .29 is higher than .6 and thus newer.

From your initial posting, didn't know you had other repos active ... should have known that ... but, guess my Vulcan Mind Meld a little off at that time.

Since you have remi, suggest erasing the webtatic repo files in /etc/yum.repos.d/ then.

So another yum mini-lesson is in order. ;)

yum repolist

will show active (those that are enabled) repos.

IF remi is active, do a yum search for php and notice the output ..... the far right column will tell you from what repo that version would be coming:

yum search php

To see if repos are enabled or disabled:

cd /etc/yum.repo.d/

fgrep 'enabled' *.repo

Wlll show all .repo files (for the different repos) and show also if enabled or not ... 0 meaning disabled and 1 being enabled.

You might have the remi repo's disabled.   And the remi repo's are quite a bit like Webtatic in that their versions of php have names like php56 or php57 or php60 or php70

To find out .... think this will work:

yum --enablerepo=remi-* list php*

On a CentOS 5 server that has both remi and webtatic some of the output of above looks like:

[root@sos yum.repos.d]# yum --enablerepo=remi-* list php*
Loaded plugins: downloadonly, fastestmirror, replace
Loading mirror speeds from cached hostfile
 * base: mirror.pac-12.org
 * extras: mirror.compevo.com
 * remi-php55: repo1.dal.innoscale.net
 * remi-php56: repo1.dal.innoscale.net
 * remi-test: repo1.dal.innoscale.net
 * updates: centos.vwtonline.net
 * webtatic-el5: us-east.repo.webtatic.com
Installed Packages
php55w.x86_64                         5.5.38-1.w5           installed          
php55w-bcmath.x86_64                  5.5.38-1.w5           installed          
php55w-cli.x86_64                     5.5.38-1.w5           installed          
php55w-common.x86_64                  5.5.38-1.w5           installed

list all the php55w-* version installed on the server am using.

Then it list other repo offerings after the label:

Available Packages

php.x86_64                            5.6.29-1.el5.remi     remi-php56         
php-PHPParser.noarch                  1.0.0-0.1.beta1.el5.remi
                                                            remi-test          
php-alcaeus-mongo-php-adapter.noarch  1.0.5-1.el5.remi      remi-test          
php-aura-di.noarch                    2.2.4-1.el5.remi      remi-test          
php-aura-router.noarch                2.3.0-1.el5.remi      remi-test          
php-aws-sdk3.noarch                   3.18.36-1.el5.remi    remi-test          
php-bcmath.x86_64                     5.6.29-1.el5.remi     remi-php56         
php-cli.x86_64                        5.6.29-1.el5.remi     remi-php56         
php-common.x86_64                     5.6.29-1.el5.remi     remi-php56         
php-dba.x86_64                        5.6.29-1.el5.remi     remi-php56 

other stuff ....

so you can see from above, IF I wanted to use remi repo and get 5.6.29 for EL5/CentoOS5 I could (with a little work).

To learn more about yum:
https://www.centos.org/docs/5/html/yum/
link above says version 5.  CentOS decided, rather than reinventing wheel, to use or refer to official RHEL docs so this might have some differences:
https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Deployment_Guide/ch-yum.html

'spirit of sharing', Ken


Average of ratings: Useful (1)
In reply to Ken Task

Re: Using the right PHP version

by Joe Amatrucola -

Thanks Ken.  Since I'm already at PHP 5.6.29 (installed from remi a few days ago), I think I'm in good shape, and now I better understand the version numbers (29 is newer than 5).  Following your instructions, I think I'll back out the webtatic repo files and call this done.  The additional yum info you provided is also very helpful.

Thank you!

Joe

In reply to Joe Amatrucola

Re: Using the right PHP version

by Jerry Lau -

Joe.. my php version is higher as its .25 not .5 so its a higher release.