Skip to content
This repository has been archived by the owner on Dec 20, 2020. It is now read-only.

CLI version sometimes drops to 5.6 #7

Open
drsassafras opened this issue Nov 7, 2018 · 6 comments
Open

CLI version sometimes drops to 5.6 #7

drsassafras opened this issue Nov 7, 2018 · 6 comments

Comments

@drsassafras
Copy link
Member

At one point I thought I had narrowed the issue down to the use of sudo, but now the PHP version seems to be stuck on 5.6, so I haven't been able to verify this.

What I did:

  1. Created a user through the ClearOS admin panel.
  2. Assigned the user to the root and wheel groups.
  3. used sudo to perform various Tiki tasks (such as svnup.php and console.php)

At one point when I was using the command line, I was getting PHP 7.1 when not using sudo, and 5.6 while using sudo. Now PHP will only return 5.6. Maybe it has to do with me trying a sudo php -v

@drsassafras
Copy link
Member Author

not7 1
5 6only

@pcbaldwin
Copy link
Contributor

It looks like something in the environment is borked. I can certainly understand general sudo issues - it scrubs environment variables. However, you're not running sudo the second time around! Check the $PATH environment variable - it needs to include /usr/clearos/bin, preferably as the first item on the list:

PATH=/usr/clearos/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin

The wrapper that handles the PHP version lives in /usr/clearos/bin/php. Feel free to add the debug switch to track down problems:

#!/bin/bash -v

@drsassafras
Copy link
Member Author

checked my $PATH

[brendan@drsassafras ~]$ echo $PATH
/usr/clearos/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/brendan/.local/bin:/home/brendan/bin

I added the debug "-v" but have no idea what it does or how to use it.

Any other thoughts about this?

@pcbaldwin
Copy link
Contributor

The path looks okay.

If you add the "-v" to the first line of /usr/clearos/bin/php and then run "php -v", it will trace through the /usr/clearos/bin/php wrapper script.

@drsassafras
Copy link
Member Author

[brendan@drsassafras ~]$ php -v
module () {  eval `/usr/bin/modulecmd bash $*`
}
#!/bin/bash -v
# Companion script to wrap multiple versions of PHP in Linux
PENV=".phpenv"

args=()
for arg in "$@";
do
	args+=("$arg")
done

# Check if there is file called .phpenv in any of the folders, from CWD to the root
# Content should be 56 (/opt/rh/rh-php56) or 70 (/opt/rh/rh-php70)
TESTDIR=$(pwd)
VER=""
while :
do
	#echo $TESTDIR
	if [ -f $TESTDIR/$PENV ]
	then
		VER=$(cat $TESTDIR/$PENV | grep '[0-9]' | head -1)
		break
	fi
	if [ "_$TESTDIR" = "_/" ]
	then
		break
	fi
	TESTDIR=$(dirname $TESTDIR)
done

#echo "/opt/rh/rh-php$VER/root/usr/bin/php"
if [ -f "/opt/rh/rh-php$VER/root/usr/bin/php" ] ; then
	cmd=(exec "/opt/rh/rh-php$VER/root/usr/bin/php" "${args[@]}")
	"${cmd[@]}"
fi

# Fallback to execute the oldest (relying on SO sorting) installed if any
#if [ -d /opt/rh/ ] ; then
#	for DIR in /opt/rh/rh-php*
#	do
#		#echo "$DIR/root/usr/bin/php"
#		if [ -f "$DIR/root/usr/bin/php" ] ; then
#			cmd=(exec "$DIR/root/usr/bin/php" "${args[@]}")
#			"${cmd[@]}"
#		fi
#	done
#fi

# Fallback to the version of the SO
cmd=(exec "/usr/bin/php" "${args[@]}")
"${cmd[@]}"
PHP 5.6.38 (cli) (built: Sep 12 2018 08:52:18) 
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
    with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies

@pcbaldwin
Copy link
Contributor

Well... that didn't help. Sorry about that.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants