Symptoms
Attempting to set the PHP handler in WHM via MultiPHP Manager returns the below error:
The supplied domain name is invalid. [php_set_handler]
The error can also be received when running cPanel updates or changing the handler manually in SSH/CLI.
whmapi1 php_set_handler version='ea-php74' handler='lsapi'
---
metadata:
command: php_set_handler
reason: "API failure: (XID afv893) The supplied domain name is invalid."
result: 0
version: 1
Description
If multiple users partially own the same domain name, it will cause issues changing PHP versions or handlers. This error is commonly caused by multiple users owning a specific file on the system at /etc/valiases/
. Correcting the ownership of the related file will resolve the issue. We've observed that these issues occur when swapping domains around between accounts where an operation may have failed or was performed incorrectly.
Workaround
Finding which files to fix is difficult, but the below steps will allow you to isolate which domain(s) are causing the issue.
- Access the server's command line as the 'root' user via SSH or "Terminal" in WHM.
- Run the following script.
- For CentOS 7, CouldLinux 7, and CloudLinux 6 servers run:
/etc/yum/universal-hooks/multi_pkgs/posttrans/__WILDCARD__-php__WILDCARD__/009-phpconf.pl
- For AlmaLinux 8 and CloudLinux 8 servers run:
/etc/dnf/universal-hooks/multi_pkgs/transaction/__WILDCARD__-php__WILDCARD__/009-phpconf.pl
- For Ubuntu 20.04 servers run:
/etc/apt/universal-hooks/multi_pkgs/Post-Invoke/__WILDCARD__-php__WILDCARD__/009-phpconf.pl
Please note that this script is normally performed after system updates are applied in EasyApache/PHP.
If a problem exists with a domain, output similar to the following is returned.
Cpanel::WebServer::Userdata::get_vhost_lang_package
(Cpanel::WebServer::Userdata=HASH(0x2daaef8), "lang",
Cpanel::ProgLang::Supported::php=HASH(0x1cc10f0), "vhost", "domain.tld")
called at /usr/local/cpanel/Cpanel/WebServer/Supported/apache.pm line 778
Try::Tiny::try(CODE(0x2da9c58), Try::Tiny::Catch=REF(0x2d4b418))
called at /usr/local/cpanel/Cpanel/WebServer/Supported/apache.pm line 788 - For CentOS 7, CouldLinux 7, and CloudLinux 6 servers run:
- Copy the problematic domain name from the output of the previous script.
Please note that the problematic domain in the above output is the example domain.tld.
- Confirm the ownership of the valiases file for that domain.
[root@server ~]cPs# stat /etc/valiases/domain.tld
Please note that in the above output, the user "wrongusername" is not the correct owner of the domain. The correct owner of the domain in this example is "rightusername."
File: /etc/valiases/domain.tld
Size: 28 Blocks: 8 IO Block: 4096 regular file
Device: 802h/2050d Inode: 2895448 Links: 1
Access: (0640/-rw-r-----) Uid: ( 1006/wrongusername) Gid: ( 12/ mail)
Access: 2019-08-18 20:08:08.954129642 -0300
Modify: 2019-01-29 18:45:41.973270387 -0300
Change: 2019-01-29 18:45:41.973270387 -0300
Birth: - - Use the
chown
command to set the correct user.chown rightusername.mail /etc/valiases/domain.tld