簡體   English   中英

如何使用cpanel api在我的服務器上托管客戶域

[英]how to host customers domain on my server using cpanel api

我在這里搜索很多

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

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

但沒有找到正確的方法。 我的要求是我需要以編程方式在服務器上托管一個域,我的客戶通過表格向我提供其域名(例如:test.com),當他提交該表格時,我將使用該網站為其設置一個wordpress網站域。 目前,我使用cpanel api以編程方式設置了一個子域,這里我的要求是在服務器上托管一個域,而我必須使用api來做到這一點。

要連接cpanel,將需要cpanel主域,cpanel用戶名和cpanel密碼。 您將與cpanel建立聯系,然后可以輕松創建新的插件域。 一旦創建了插件域,就可以使用單個插件域來專門管理每個域。

    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);

上面我建議了在cpanel上創建插件域的方法。 以下是在WHM或服務器上生成新的cpanel帳戶的代碼

$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));

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM