24

Is there a way that I can permanently enable a SCL?

I've installed rh-php56, and I would like to make sure that it is loaded every time I ssh into my machine.

I am currently running CentOS 7.

Odyss3us
  • 355
  • 1
  • 2
  • 8

3 Answers3

50

using scl enable actually opens a new shell inside your current one, which is quite unclean, especially if done from a login script.

You should place, instead, in your ~/.bash_profile:

source /opt/rh/rh-nginx18/enable

or:

source scl_source enable rh-nginx18

The latter is more "elegant" as it is independent from the actual installation path.

This has the effect of loading the environment in your current shell.

l3g3nd4ryf0x
  • 616
  • 6
  • 4
  • this also works on amazon linux Linux ip-10-1-129-214 4.14.238-125.422.amzn1.x86_64 #1 SMP Tue Jul 20 20:51:46 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux – retgoat Feb 23 '22 at 05:45
23

Redhat proposes placing a file in /etc/profile.d, i.e. for python:

$ cat /etc/profile.d/enablepython33.sh
#!/bin/bash
source scl_source enable python33

As this works for the devtools under centos for me you could try this.

ted
  • 333
  • 3
  • 6
-3

I think you could add a line into your shell profile (e.g. ~/.bash_profile) to enable your scl of choice. For example,

scl enable rh-nginx18 bash

EDIT: marked as spoiler since this is dangerous

Reload your profile or logout/login, and you should have access to your SCLs.

olore
  • 103
  • 4
  • 7
    One problem with this is that your resulting bash is no longer a login shell. And you can't _make_ it a login shell. If you try, you'll fork bomb your system. This may work in some circumstances, but it's not the recommended method. – Michael Hampton Jan 10 '18 at 02:59
  • 4
    CAREFUL! Adding an scl command like the above just got me a "frozen" login because the script got stuck for some reason. Have this page for a handy reference for when you get locked out: https://serverfault.com/questions/94503/login-without-running-bash-profile-or-bashrc – Lance Kind Aug 22 '19 at 21:33
  • 1
    The accepted response is DANGEROUS, and should be somehow demoted or removed. Adding this so maybe people will notice it before forkbombing themselves :) – Dan Vatca Dec 04 '19 at 08:14
  • This fork bombed me and should be instantly removed. – Michael Chourdakis Dec 02 '20 at 22:17