【问题标题】:how to host customers domain on my server using cpanel api如何使用 cpanel api 在我的服务器上托管客户域
【发布时间】:2017-03-01 14:05:41
【问题描述】:
【问题讨论】:
标签:
web-hosting
cpanel-xmlapi
【解决方案1】:
上面我已经建议了在 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));
【解决方案2】:
要连接 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);