11

I have installed RHSCL 2 using the following url:

https://access.redhat.com/documentation/en-US/Red_Hat_Software_Collections/2/html/2.0_Release_Notes/chap-Installation.html

using the RedHat subscription manager.

I then ran yum remove php* followed by yum install rh-php56

Everything went smoothly except now PHP is not found anywhere. I then ran find / -name php and found rh-php56 in the following directories:

/var/opt/rh/rh-php56/lib/php
/opt/rh/rh-php56/register.content/var/opt/rh/rh-php56/lib/php
/opt/rh/rh-php56/root/usr/bin/php
/opt/rh/rh-php56/root/usr/lib64/php
/opt/rh/rh-php56/root/usr/share/php

What is the best way to get these binaries into /usr/bin or any other directory that is usually globally available for all users?

Did I miss a step when installing the packages which is why it is not available globally? Or is this just what happens when using RHSCLs?

I have tested the binaries in those folders and they work when I run php -v so it is working fine.

My first thought is to just cp into /bin or /usr/bin but maybe there is an official way to do what I am asking?

edit

Cannot comment, no rep... from chapter 3 of the link I posted, it says that software collection packages must be run like so:

scl enable rh-php56 'php -v'

Which does work... however how do I get it to run for all users like $ php -v with no additional commands. I need the php binaries globally available so webservers can use it and ssh users with normal shells.

3
  • You forgot to read chapter 3 of the link you gave....
    – Sven
    Oct 9, 2015 at 8:54
  • 1
    Sven... I read it myself.. and all it has is starting a sub-shell with the collection made available. It does NOT detail how to make a collection available BY default without the user needing to run a sub-shell. I will detail a proper solution below.
    – anthony
    Feb 11, 2016 at 1:51
  • Sven, that would mean that every user and every daemon would need to run scl enable rh-php56 command, which is complicated. Enabling it globally via @antofthy's answer is much more elegant. Feb 13, 2016 at 1:29

1 Answer 1

17

The way to import a software collection into your current shell (not launch a sub-shell) is to source the "enable" file.

For example for rh-php56 on a Redhat 7 machine...

source /opt/rh/rh-php56/enable

You can now run "php", or read manpages "man php" as normal.

that will add the appropriate environment variables to the current shells environment. Individual users can do this in there .bashrc files, allowing it to be available from SSH (non-interactive shells)

You can also copy (or symlink) the enable file into /etc/profile.d/ with a ".sh" suffix to automatically enable it for ALL users.

For example

ln -s /opt/rh/rh-php56/enable /etc/profile.d/rh-php56.sh

Becareful doing this if more than environment is needed (such as daemons?). Or if multiple versions of that software is present on a system (for backward compatibility with other software/services), as there may be interaction between versions. Also users may not want the 'latest' version, or become confused as to why the 'base' system (EG: /etc configs) does not effect the software collection version.

Anthony Thyssen (A very old system Admin)

5
  • which instance of php.ini does this method invoke?
    – Darvanen
    Jul 6, 2016 at 7:22
  • 1
    The php.ini file read is hard coded into the php program. In the above example it is "/etc/opt/rh/rh-php56/php.ini". You can verify this using the PHP script <?php phpinfo() ?> either from a ".php" web page, or using the CLI PHP command.
    – anthony
    Jul 7, 2016 at 23:23
  • Ahhh... I was restarting httpd instead of the php-fpm service. Posting here in case anyone else gets stuck that way.
    – Darvanen
    Jul 13, 2016 at 0:36
  • Is this actually sufficient to enable a SCL package? access.redhat.com/solutions/527703 seems to create a bash script which does something like source scl_source enable python33 Jun 27, 2017 at 22:50
  • Should be sufficient. It basically sets the environment to use the specific version over the system version. But only within the sub-shell started.
    – anthony
    Jul 19, 2017 at 2:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .