Enable cpapi2 in CageFS
  1. Forums
  2. CloudLinux and Control Panels
  3. CloudLinux and cPanel
  1. Ibra
  2. 28.08.2018
  3.  Subscribe via email

I'm trying to enable the cpapi2 command, but I can't get it to work fully.

I created a file, cpapi2.cfg, in /etc/cagefs/conf.d containing the following:

comment=cPanel API v2

and executed:

cagefsctl --force-update

I then ran cpapi2 a regular user and the following was shown:

Utility to execute cPanel API calls

cpapi2 [options] [module] [uri-key=uri-value] [uri-key=uri-value] ....

Additional documentation is available at https://go.cpanel.net/api2docs

IMPORTANT: “uri-key” and “uri-value” represent URI-escaped strings.[*]

The serialization format to use for output.

The serialization format to use for input.
- key-value (default) - uri-key=uri-value pairs as arguments
- json - Read JSON from stdin (currently only supported for WHM API 1)

The user to run the API call as. REQUIRED when running “bin/apitool.pl” as root.

Prints this help text.
Can't locate Cpanel.pm in @INC (you may need to install the Cpanel module) (@INC contains: /usr/local/cpanel /usr/local/cpanel/3rdparty/perl/526/lib64/perl5/cpanel_lib/x86_64-linux-64int /usr/local/cpanel/3rdparty/perl/526/lib64/perl5/cpanel_lib /usr/local/cpanel/3rdparty/perl/526/lib64/perl5/5.26.0/x86_64-linux-64int /usr/local/cpanel/3rdparty/perl/526/lib64/perl5/5.26.0 /opt/cpanel/perl5/526/site_lib/x86_64-linux-64int /opt/cpanel/perl5/526/site_lib) at /usr/local/cpanel/Cpanel/ApiInfo/UAPI.pm line 13.
BEGIN failed--compilation aborted at /usr/local/cpanel/Cpanel/ApiInfo/UAPI.pm line 13.
Compilation failed in require at /usr/local/cpanel/Cpanel/Template/Plugin/API_Shell.pm line 12.
BEGIN failed--compilation aborted at /usr/local/cpanel/Cpanel/Template/Plugin/API_Shell.pm line 12.
Compilation failed in require at bin/apitool.pl line 462.

Am I doing something wrong here? Any idea on how to get it working?
I'd appreciate some help! : )
Rate this post:
  1. 29.08.2018 15:08:37
  2. # 1
Michael Accepted Answer
Posts: 4
Joined: 29.08.2018
Hello @Ibra,

You can grant access to the cpapi2 binary for caged users by adding the full path to the /etc/cagefs/custom.proxy.commands file per the instructions in the following document:


For example:

# cat /etc/cagefs/custom.proxy.commands

# cagefsctl --force-update

I tested and confirmed this works as expected:

# cpapi2 Ftp listftp
apiversion: 2
homedir: /home/username
type: main
user: username
homedir: /usr/local/apache/domlogs/username
type: logaccess
user: username_logs
result: 1
func: listftp

Let me know if you have any questions.

  1. 29.08.2018 15:08:36
  2. # 2
Aleksei Faians Accepted Answer
Posts: 21
Joined: 02.04.2018

Yes, you can do as Michael suggested. Or you can just add /usr/local/cpanel/Cpanel.pm to paths in cpapi2.cfg, like this:

# cat /etc/cagefs/conf.d/cpapi2.cfg
comment=cPanel API v2

And then execute "cagefsctl --force-update".
  1. 29.08.2018 16:08:24
  2. # 3
Ibra Accepted Answer
Posts: 0
Joined: 20.01.2021
@Aleksei Faians

I tried your suggestion, but it didn't work unfortunately.

As a test, I ran cpapi2 Ftp listftp which returned:

[2018-08-29 18:07:00 +0200] warn [cpapi2] Failed to execute /usr/local/cpanel/cpanel: No such file or directory at /usr/local/cpanel/Cpanel/XML.pm line 114.
Cpanel::XML::cpanel_exec_fast(HASH(0x8975b0), HASH(0xfa38e0)) called at bin/apitool.pl line 206
bin::apitool::_run_cpanel_function("yaml", HASH(0x8975b0), HASH(0xf45b50)) called at bin/apitool.pl line 146
bin::apitool::_cpanel_api_handler(__CPANEL_HIDDEN__, HASH(0xf45b50), __CPANEL_HIDDEN__, __CPANEL_HIDDEN__, ARRAY(0x897b20)) called at bin/apitool.pl line 108
bin::apitool::run("Ftp", "listftp") called at bin/apitool.pl line 37
warn [cpapi2] Failed to execute /usr/local/cpanel/cpanel: No such file or directory
Failed to execute /usr/local/cpanel/cpanel: No such file or directory at bin/apitool.pl line 209.

Thanks for replying though!


Your solution worked great! Cheers! :)
  1. 29.08.2018 16:08:43
  2. # 4
Aleksei Faians Accepted Answer
Posts: 21
Joined: 02.04.2018

Thank you for update. Indeed, this tool requires more stuff to be added to CageFS, so using proxyexec method (suggested by Michael) is actually better here.
  • Page :
  • 1

There are no replies made for this post yet.
Be one of the first to reply to this post!
Submit Your Response
Upload files or images for this discussion by clicking on the upload button below. Supports gif,jpg,png,zip,rar,pdf
• Insert • Remove Upload Files (Maximum File Size: 2 MB)
To protect the site from bots and unauthorized scripts, we require that you enter the captcha codes below before posting your question.

EU e-Privacy Directive

This website uses cookies to ensure you get the best experience using our website and services. If you prefer we don’t use cookies, please disable them in your browser.

You have declined cookies. This decision can be reversed.

You have allowed cookies to be placed on your computer. This decision can be reversed.