monu21987
monu21987

Reputation: 48

how to host customers domain on my server using cpanel api

i am searching a lot here

https://documentation.cpanel.net/display/SDK/Guide+to+cPanel+API+2

https://documentation.cpanel.net/display/SDK/Guide+to+cPanel+API+1

but didn't found any correct way. what my requirement is i need to host a domain on my server programmatically, where my clients provide me its domain name (ex: test.com) via a form and when he submit that form, i will set a wordpress site for it using that domain. Currently i setup a subdomain programmatically using cpanel api, what my requirement here is hosting a domain on my server and i have to do this using api.

Upvotes: 0

Views: 1303

Answers (2)

jagjeet
jagjeet

Reputation: 377

Above I have suggested the way to create addon domain on a cpanel. Hereunder is the code to generate new cpanel account on WHM or server

$xmlapi = new \xmlapi($reseller->url);
//checking authentication of the cpanel
$xmlapi->password_auth($reseller->username, $reseller->password);                                                   
$xmlapi->set_port(2087);
$xmlapi->set_output('json');

$conf = array("username"=>$username,"password"=>$password,"domain"=>$domain,"pkgname"=>$package,"contactemail"=>$contactemail,"cpmod"=>"x3");

$result = json_decode($xmlapi->createacct($conf));

Upvotes: 0

jagjeet
jagjeet

Reputation: 377

To connect with cpanel, you will be needed cpanel main domain, cpanel username and cpanel password. You will get connected with cpanel and then can easily create new addon domains. Once you get created addon domain then you can use individual addon domain to manage each domain specifically.

    require_once '../components/xmlapi.php';

    $xmlapi = new \xmlapi($licence['cpanel_domain']);
    //checking authentication of the cpanel
    $xmlapi->password_auth($licence['username'],$licence['password']);

    $xmlapi->set_port(Yii::$app->params['domainPort']);

    $result = $xmlapi->api1_query($licence['password'], 'CustInfo', 'getemail', array());   

    // Add the "addondomain.com" addon domain.

    $api2args = array(
         'dir'            => 'addondomain/home/dir', 
         'newdomain'      => 'addondomain.com', 
         'subdomain'      => 'subdomain',
    );

    $add_addon = $xmlapi->api2('AddonDomain', 'addaddondomain', $api2args);

Upvotes: 0

Related Questions