Skip to main content

How do we create a sub-domain in cPanel from WordPress

Comments

5 comments

  • cPanelTJ
    Hi @c3PanoH If you want to add subdomains via the cPanel API, you'll want to use LiveAPI PHP system to call the API using PHP. LiveAPI does not require API Token authentication when run locally on the server. The API call would look something like this: [CODE=php]$cpanel = new CPANEL(); // Connect to cPanel - only do this once. // Create a subdomain. $get_userdata = $cpanel->uapi( 'SubDomain', 'addsubdomain', array( 'domain' => 'subdomain', 'rootdomain' => 'example.com', 'dir' => '/public_html/directory_name', 'disallowdot' => '1', ) );
    0
  • c3PanoH
    Thanks for the quick reply @cPanelTJ - ahha! That's the page i should've landed on; the one i found must have been the deprecated API linking to this page but i went astray somewhere! Ill give this a shot ... much appreciated, Cheers
    0
  • c3PanoH
    Hi again, Ive just tried the UAPI and hit a problem - im getting an error which suggests CPanel API is not configured by my host and after contacting them they say they cannot offer configuration for this feature. The error appears when i use the basic browser-based call to the Subdomain module - thus : The system failed to load the module "Cpanel::API::SubDomain" because of an error: Can't locate Cpanel/API/SubDomain.pm in @INC (you may need to install the Cpanel::API::SubDomain module) ... etc ...
    The prototype of the url method used is: https://hostname.example.com:2083/cpsess##########/execute/SubDomain/addsubdomain?domain=subdomain&rootdomain=example.com&dir=%2Fpublic_html%2Fdirectory_name&disallowdot=1
    This being a test which i thought would give me an idea of my servers capability - so i was surprised that this simple method doesn't work before i try the PHP API method. Is there anything i can do here? I have admin and SSH access to my server @ SiteGround.
    0
  • cPanelTJ
    @c3PanoH Your server may be on an earlier product version; these UAPI subdomain calls were added recently in cPanel&WHM version 11.86. My favorite way to test the functionality and output of one of our APIs is over the Command Line. You can do it as root for WHM API, as root impersonating a user for any cPanel API, and as any user for any cPanel API. Each API documentation page includes an example of calling the API over Command Line. Please let me know the cPanel&WHM version of your server, and we may be able to identify some alternatives for you!
    0
  • c3PanoH
    I think i may have overlooked a point here ( I've slapped the back of my own legs and sent myself to bed with no pudding ). I dont see WHM as an option, not only in my CPanel but indeed any host package offered by my host.. I contact them over the weekend and they did confirm my suspicions. Anything described as 'reseller' is actually their own custom interface. They dont provide root access to any package whether it be the shared, dedicated or cloud; top of the range, hosting. They've been great up until now and i've no issue with them at all; i think my projects' needs have just outgrown their services. I drew up a short list a few months ago before settling with them - ill now change to my 'plan-B' host.
    0

Please sign in to leave a comment.