Identify all users assigned a PHP version

bloatedstoat

Well-Known Member
Jun 14, 2012
216
33
78
Victoria, Australia
cPanel Access Level
Root Administrator
Hello,

We use the CloudLinux PHP selector to assign a PHP version.

Is it possible, without having to plough through each username individually, all users currently assigned PHP v5.6 for example?

I can see how this is done on a per account basis but I am seeking a list of all users assigned a PHP version. It's really time consuming doing this per account and I am inherently lazy so looking for the path of least resistance. Command line preferably.

Thanks.
 

bloatedstoat

Well-Known Member
Jun 14, 2012
216
33
78
Victoria, Australia
cPanel Access Level
Root Administrator
@Infopro In my case every domain displays PHP5.6 in MultiPHP Manager in WHM. The versions actually deployed are mostly version 7 by way of the CloudLinux PHP Selector chosen in cPanel. I've never used MultiPHP Manager in WHM.

@cPanelLauren thanks, it does in a fashion. My knowledge of command line voodoo is limited, ideally I'd like a command that displays all users of a "chosen" version listed next to just the username. The output from the one on the CL forum is overly verbose and cluttered - especially when dealing with lots of accounts. I'm sure there's a way to do this ... he said whilst throwing down the gauntlet ....
 
  • Like
Reactions: Infopro

cPanelLauren

Product Owner II
Staff member
Nov 14, 2017
13,266
1,304
363
Houston
Hi @bloatedstoat

How about this?

Code:
 for user in /var/cpanel/users/*;do if [[ ! "${user##*/}" = system ]]; then php="$(selectorctl -c -u "${user##*/}" 2>&1)";echo "${user##*/} ${php%%$'\t'*}";fi;done
I can't take all the credit for this though, one of my coworkers is a genius with one-liners like this.
 

SS-Maddy

Well-Known Member
Mar 28, 2009
130
18
68
cPanel Access Level
Root Administrator
Hi @bloatedstoat

How about this?

Code:
 for user in /var/cpanel/users/*;do if [[ ! "${user##*/}" = system ]]; then php="$(selectorctl -c -u "${user##*/}" 2>&1)";echo "${user##*/} ${php%%$'\t'*}";fi;done
I can't take all the credit for this though, one of my coworkers is a genius with one-liners like this.
Loved this. Tweeted too :)
 
  • Like
Reactions: cPanelLauren

jonathan.mann

Registered
Nov 6, 2019
3
0
1
Columbus, Ohio
cPanel Access Level
Root Administrator
Hello! As long as you're using EasyApache 4, you should be able to utilize "MultiPHP Manager" in WHM.

I had issues sorting via php version. It appeared the search was limited to domain? "whmapi1 php_get_vhost_versions" works too, and I'm close to what I need with that.

Using:
Code:
whmapi1 php_get_vhost_versions | egrep 'account:|version:|vhost:' | sed 's/vhost/domain/'
Can I include some kind of modifier in this to only list active accounts/domains?