In the past on my old server (CentOS7; cPanel 68), my Perl script called the API function addsubdomain to create a new subdomain. On my new server (CentOS7, cPanel 70.0.44), the same code returns an error from the addsubdomain API call:
"You must choose a docroot that the system does not reserve"
I checked Tweak Settings->Restrict document roots to public_html and it is ON.
In my script I set up the call to the API using this URL:
This worked previously with no "dir" parameter being passed (i.e. default). Now it issues the above error message. In the cPanel API docs, it says for the "dir" parameter:
------------------------------------------------------------------------
The subdomain's document root within your home directory.
This parameter's default depends on the server's settings:
cPanel & WHM version 58 and higher:
- If the Restrict document roots to public_html value is On, the parameter defaults to the public_html/subdomain_namepath, where subdomain_name is the subdomain's name.
- If the Restrict document roots to public_html value is Off, the parameter defaults to the subdomain_name path, where subdomain_name is the subdomain's name.
------------------------------------------------------------------------
Since my setting is ON, the dir param should default to public_html/$newsubdomain in my case, which is what I want it to do, and that's where it created the new subdomains in the past on my old server without any problems.
On the new server, however, if I explicitly add
to the end of the the URL, it properly creates the subdomain as public_html/$newsubdomain as it used to.
Since the Restrict document roots to public_html setting is ON, I would expect that if I didn't specify &dir, it would have defaulted to the same value I passed when I added the &dir=public_html/$newsubdomain parameter explicitly.
Am I missing something or should my call work the old way (without &dir) if I want to create public_html/$newsubdomain?
Thanks!
"You must choose a docroot that the system does not reserve"
I checked Tweak Settings->Restrict document roots to public_html and it is ON.
In my script I set up the call to the API using this URL:
Code:
$URI = "http://$g_accounthost:2082/json-api/cpanel?user=$g_accountuserid&cpanel_jsonapi_module=SubDomain&cpanel_jsonapi_func=addsubdomain&cpanel_jsonapi_apiversion=2&domain=$newsubdomain&rootdomain=$g_accountdomain
------------------------------------------------------------------------
The subdomain's document root within your home directory.
This parameter's default depends on the server's settings:
cPanel & WHM version 58 and higher:
- If the Restrict document roots to public_html value is On, the parameter defaults to the public_html/subdomain_namepath, where subdomain_name is the subdomain's name.
- If the Restrict document roots to public_html value is Off, the parameter defaults to the subdomain_name path, where subdomain_name is the subdomain's name.
------------------------------------------------------------------------
Since my setting is ON, the dir param should default to public_html/$newsubdomain in my case, which is what I want it to do, and that's where it created the new subdomains in the past on my old server without any problems.
On the new server, however, if I explicitly add
Code:
&dir=public_html/$newsubdomain
Since the Restrict document roots to public_html setting is ON, I would expect that if I didn't specify &dir, it would have defaulted to the same value I passed when I added the &dir=public_html/$newsubdomain parameter explicitly.
Am I missing something or should my call work the old way (without &dir) if I want to create public_html/$newsubdomain?
Thanks!