Get Virtualizor

Change Hostname

Use the change hostname API to change the hostname of the server. The API response will contain "done" as "1" after the hostname is updated.

The changes will be reflected only after the server reboots.

HTTP Request

https://hostname:4085/index.php?act=hostname

Parameters

NameMethodValueDescriptionRequired
actGEThostnameThe action specified to perform operation and retrieve dataYes
changehostPOST1/0This should be set as 1 for updating the hostnameYes
newhostPOSTtextSet the new hostnameYes

Sample Code

<?php

    require_once('/usr/local/virtualizor/sdk/admin.php');

    $key =  'your_api_key';
    $pass = 'your_api_pass';
    $ip = 'your_server_ip';

    $admin = new Virtualizor_Admin_API($ip, $key, $pass);

    $post = array();
    $post['changehost'] = 1;
    $post['newhost'] = 'test.hostname';

    $output = $admin->hostname($post);

    print_r(json_encode($output));

?>

Output

{
    "title": "Hostname",
    "done": 1,
    "timenow": 1536247931,
    "time_taken": "0.246"
}
    Was this page helpful?
    Newsletter Subscription
    Subscribing you to the mailing list