Use Change Hostname API to change hostname of your VPS on your server.
HTTP Request
https://hostname:4083/index.php?act=hostname&svs=vpsid
Parameters
Name | Type | Value | Description | Required |
---|---|---|---|---|
act | GET | Int | The action specified to return data | Yes |
svs | POST | Int | The vpsid whose hostname needs to be changed | Yes |
newhost | POST | newhost | The new hostname of the vps | Yes |
Sample Code
PHP
<?php
require_once('/usr/local/virtualizor/sdk/enduser.php');
$key = '';
$pass = '';
$ip = '';
$admin = new Virtualizor_Enduser_API($ip, $key, $pass);
$post = array();
$hostname = 'Test-hostname12';
$vid = 3384;
$output = $admin->hostname($vid, $hostname);
print_r(json_encode($output));
?>
Curl
curl -k -X POST -d "changehost=1&newhost=test_api"
-L "https://hostname:4083/index.php?act=hostname&svs=3577&api=json&
apikey=your_api_key&apipass=your_api_pass&do=1"
Output
{
"uid": "321",
"act": "hostname",
"timezone": 1,
"timenow": "September 23, 2016, 6:04 am",
"vpsid": "3008",
"username": "test@test.com",
"user_type": "2",
"preferences": {
"fname": "test",
"lname": "test",
"language": "english",
"theme": "default",
"timezone": 1,
"logo": ""
},
"url": "index.php?",
"rdns": {
"pdnsid": null
},
"support_link": "http://softaculous.com",
"disable_login_logo": 1,
"title": "Hostname",
"done": {
"msg": "Your hostname will be changed when the VPS is booted again"
},
"onboot": "Your hostname will be changed when the VPS is booted again",
"current": "OpenVZSlave2_dnd",
"time_taken": "1.365"
}