These forums are locked and archived, but all topics have been migrated to the new forum. You can search for this topic on the new forum: Search for API PHP Create-Domain Always Exit Status 256 on the new forum.
Hello,
I want to create a php program to automatically create virtual-server and sub-server on Virtualmin Server. Here is my code
<?php
//init curl and set options
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://sub.server.com:10000/virtual-server/remote.cgi');
curl_setopt($ch, CURLOPT_USERPWD, 'root:rootpass');
//using self signed ssl cert, so dont verify
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_TIMEOUT , 300);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_POST, TRUE);
//set command to execute here
//
$param = [
'program' => 'create-domain',
'domain' => 'sub.domain.com',
'pass' => '123456',
'web' => '',
'dir' => '',
'unix' => ''
];
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($param));
//execute curl request
$result = curl_exec($ch);
curl_close($ch);
//see result
echo $result;
?>
When I execute that code on a web browser, the new domain successfully created on the server, but the code always return a message "You are already hosting this domain" with exit status of 256. Does it should return the Exit Status : 0, instead of 256?
If I execute using wget code as on Virtualmin example on command line, it works perfectly with Exit status : 0. Any idea how to solve this? Thanks..