Description


This function changes the server's hostname.


  • Do not select a hostname that begins with www or a number, or a hostname that ends with a hyphen (-).
  • You must use a fully-qualified domain name (FQDN) that contains two periods (for example, hostname.example.com).
  • Do not choose a hostname that a cPanel account on your server will use.
  • Do not choose a potential service subdomain (proxy subdomain) as a hostname (for example, cpanel.example.com or whm.example.com).

Examples 




https://hostname.example.com:2087/cpsess##########/json-api/sethostname?api.version=1&hostname=hostname.example.com




https://hostname.example.com:2087/cpsess##########/xml-api/sethostname?api.version=1&hostname=hostname.example.com




whmapi1 sethostname hostname=hostname.example.com



{
  "metadata": {
    "version": 1,
    "reason": "Hostname set to: hostname.example.com",
    "output": {
      "warnings": "The hostname was already set to hostname.example.com, syncing configuration only.",
      "messages": "Updating cPanel license...Done. Update succeeded.\n
Building global cache for cpanel...Done\n
Updating cPHulkd\nhulkdsetup: database schema is up to date."
    },
    "result": 1,
    "command": "sethostname"
  }
}




<result>
    <metadata>
        <version>1</version>
        <reason>Hostname set to: hostname.example.com</reason>
        <output>
            <warnings>
                The hostname was already set to hostname.example.com, syncing configuration only.
            </warnings>
            <messages>
                Updating cPanel license...Done. Update succeeded. 
Building global cache for cpanel...Done
Updating cPHulkd hulkdsetup: database schema is up to date.
            </messages>
        </output>
        <result>1</result>
        <command>sethostname</command>
    </metadata>
</result>



   

Parameters

ParameterTypeDescriptionPossible valuesExample
hostnamestring

Required

The server's new hostname.


 

A valid hostname.

The server's hostname should never be identical to the domain name. For example, if the domain is example.com, you could use a hostname such as server1.example.com, but not example.com.  


hostname.example.com

Returns

The function outputs these returns in the metadata.


ReturnTypeDescriptionPossible valuesExample
outputhash

A hash of the function's output.

This hash includes the warnings and messages returns. 

warnings

string

Any of the function's warnings.

The function returns this value in the output hash.

A valid string.The hostname was already set to hostname.example.com, syncing configuration only.

messages

string

Any of the function's output messages.

The function returns this value in the output hash.

A valid string.

Updating cPanel license...Done. Update succeeded.

Building global cache for cpanel...Done

Updating cPHulkd hulkdsetup: database schema is up to date.