The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Subdomain integration

Discussion in 'cPanel Developers' started by Zeeble, Jan 13, 2010.

  1. Zeeble

    Zeeble Registered

    Joined:
    Jan 13, 2010
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    Hi,

    Let me start first by saying that I have never done any integration with Cpanel before, so I really appreciate your help and hope that you understand that some of my questions my be basic. Thank you.

    I have a forum which will also shortly be offering a blog service. The forum is currently hosted on a server with Cpanel/WHM and I want to be able to to integrate the site so that when one of my users registers it will automatically generate a subdomain of their choosing.

    Here's where it gets a little more complicated: The forum (Vbulletin 4.0 Publishing Suite) creates the blog and currently sets into simply creates a new folder for the blog and not a whole new Cpanel hosting account which is what normally happens when a subdomain is created in Cpanel.

    Can someone give me some advice on (first of all) on the API system as I know nothing about it and secondly some information on my above issue.

    Many thanks,
    Colin
     
  2. MattDees

    MattDees cPanel Product Owner
    Staff Member

    Joined:
    Apr 29, 2005
    Messages:
    417
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    Colin, before I respond to this with some in-depth answer, I want to ensure I have the question correct

    You want to create a subdomain that points toa folder within your public_html/ directory via the APIs.

    Correct?
     
  3. Zeeble

    Zeeble Registered

    Joined:
    Jan 13, 2010
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    Thanks very much for responding so quickly. And yes, that's what I want to do :)

    -Colin
     
  4. MattDees

    MattDees cPanel Product Owner
    Staff Member

    Joined:
    Apr 29, 2005
    Messages:
    417
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    Ok, cool, this is actually pretty easy to do. What you will need to do is use the XML-API PHP class to call SubDomain::addsubdomain API2 call.

    This call already does exactly what you are looking to do. It will:

    Create the Folder
    Create the Subdomain in ALL required places in cPanel

    After this, any files that will need to be copied.. can be. Be sure to use SuPHP if this is the case otherwise the files may end up owned by the user "nobody" rather than the correct user.

    An example of using the XMLAPI PHP class for this would be:

    PHP:
    include("xmlapi.php");
    $ip "127.0.0.1";
    $account "someuser";
    $password "somepass";

    $xmlapi = new xmlapi($ip);
    $xmlapi->password_auth($account,$password);
    $xmlapi->set_port('2082');

    $args = array(
      
    domain=> "subdomain"
      
    rootdomain=> "mydomainname.com",
      
    dir => "public_html/directory"
    ); 

    $xmlapi->set_debug(1);
    print 
    $xmlapi->api2_query($account"SubDomain""addsubdomain"$args );
     
    #4 MattDees, Jan 14, 2010
    Last edited: Jan 25, 2010
  5. Zeeble

    Zeeble Registered

    Joined:
    Jan 13, 2010
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    Fantastic, thank you very much for helping me out there. I'll post an update if I have any issues.

    Have a great weekend!
     
  6. dotcomtim

    dotcomtim Member

    Joined:
    Jan 20, 2010
    Messages:
    11
    Likes Received:
    0
    Trophy Points:
    1
    I am looking for the exact same solution and tried this. Followed the steps and enter my server details and account. Nothing happened. Is there something missing? From the instructions I am not aware of?
     
  7. MattDees

    MattDees cPanel Product Owner
    Staff Member

    Joined:
    Apr 29, 2005
    Messages:
    417
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    Try now, I made a typo in my original post "login" should have been "rootdomain"


    What error message are you getting?
     
  8. dotcomtim

    dotcomtim Member

    Joined:
    Jan 20, 2010
    Messages:
    11
    Likes Received:
    0
    Trophy Points:
    1
    This is what I am using; when I run the script I get nothing just a blank screen with no errors or success. Still does not add the subdomain.

    include '../functions/config.php';
    include '../functions/xmlapi.php';
    $ip = 'ip to the server';
    $domain = 'domain to create sub under';
    $sub = 'test';

    $xmlapi = new xmlapi($ip);
    $xmlapi->password_auth(CP_ACCOUNT, CP_PASSWORD);
    $xmlapi->set_port('2082');

    $args = array(domain => $sub, rootdomain => $domain, dir => 'public_html');

    $xmlapi->set_debug(1);

    print $xmlapi->api2_query(CP_ACCOUNT, 'SubDomain', 'addsubdomain', $args);

    The CP_ACCOUNT and CP_PASSWORD are defined and drawn from outside of root through the config.php file. The account username and password that I am using are the same username and password to sign in to the cpanel for that domain. Is this correct or should it be the root and password? I like to create a subdomain under the main directory, I am using test and no directory or subdomain created for test when the script is run.

    xmlapi.php - latest version 1.0.3

    Does anything in the server have to turned on?
     
  9. MattDees

    MattDees cPanel Product Owner
    Staff Member

    Joined:
    Apr 29, 2005
    Messages:
    417
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    Ok, when executing this, are you doing it from shell or via apache?

    If it's via apache there may be an error in /usr/local/cpanel/logs/error_log, if it's via shell, check where ever you have PHP set to log to.
     
  10. dotcomtim

    dotcomtim Member

    Joined:
    Jan 20, 2010
    Messages:
    11
    Likes Received:
    0
    Trophy Points:
    1
    Yep I got errors - each time I ran the script I get Cpanel::IxHash: Warning, mangling data key udir which is longer then 64 bytes, using safe_html_encode followed by several lines of code.

    I found several posts similar each suggesting disabling NSCD, is this ok? Where would one go to disable it?
     
  11. MattDees

    MattDees cPanel Product Owner
    Staff Member

    Joined:
    Apr 29, 2005
    Messages:
    417
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    Disabling NSCD may not be the way to fix this. I strongly urge that you open a ticket at tickets.cpanel.net/submit/ please title it: "ATTN: Matt Dees SubDomain integration" so that I can take a look at it.

    With this ticket I will need access to your system.
     
Loading...

Share This Page