我是MediaTemple托管新手。 我需要创建子域,这将打开主站点,因此无需为子域创建任何文件或文件夹。因此,域和子域将显示来自相同源的相同内容。
我搜索了很多但找不到任何有用的信息。我已经通过以下函数在HostGator托管上通过php脚本成功创建了子域。但现在我想在MediaTemple托管上通过php脚本创建子域名。
public function create_subdomain($subDomain,$cPanelUser,$cPanelPass,$rootDomain,$subDomainDir)
{
$buildRequest = "/frontend/x3/subdomain/doadddomain.html?rootdomain=" . $rootDomain . "&domain=" . $subDomain . "&dir=" . $subDomainDir;
$openSocket = fsockopen('localhost',2082);
if(!$openSocket) {
return "Socket error";
exit();
}
$authString = $cPanelUser . ":" . $cPanelPass;
$authPass = base64_encode($authString);
$buildHeaders = "GET " . $buildRequest ."\r\n";
$buildHeaders .= "HTTP/1.0\r\n";
$buildHeaders .= "Host:localhost\r\n";
$buildHeaders .= "Authorization: Basic " . $authPass . "\r\n";
$buildHeaders .= "\r\n";
fputs($openSocket, $buildHeaders);
while(!feof($openSocket)) {
fgets($openSocket,128);
}
fclose($openSocket);
$newDomain = "http://" . $subDomain . "." . $rootDomain . "/";
return "Created subdomain $newDomain";
}