Skip Navigation

Generate a list of PHP versions being used by accounts on a WHM server.

Something I wondered recently after seeing a colleague of mine trawl through accounts on a WHM to get PHP versions was how I could make this process less painful.

Attached is a handy little snippet which you can modify if needed.

Generates a list like

accountname,php8
accountname2,php74

The script does the following:

  • Loopsthrough each user within the /var/cpanel/users/ directory
  • Uses the selectorctl command to retrieve the PHP version configured for each account
  • Outputs the account name and corresponding PHP version in a comma-separated format.
  • Output a comma seperated list of WHM account names and PHP version numbers.sh
    for user in /var/cpanel/users/;do if [[ ! "${user##/}" = system ]]; then php="$(selectorctl -c -u "${user##/}" 2>&1)";echo "${user##/},${php%%$'\t'*}";fi;done