12

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.

30

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.

| improve this answer | |
  • Really elegant, I like this one a lot more – Jean-Bernard Jansen Dec 10 '18 at 22:39
  • This solution works nicely and doesn't have the "spawning another bash" problem like the current "correct" solution. – Lance Kind Aug 22 '19 at 22:48
15

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.

| improve this answer | |
  • 3
    This is what I do. I've created an /etc/profile.d/scl_enable.sh file with all of my scl files in that one file. – Jarrett Meyer Sep 26 '18 at 13:31
0

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

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

| improve this answer | |
  • 6
    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 2:59
  • 3
    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: serverfault.com/questions/94503/… – Lance Kind Aug 22 '19 at 21:33
  • 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 4 '19 at 8:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.