如何使用 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));
我在这里搜索了很多
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));