Overview
The /usr/local/cpanel/bin/set_hostname
utility updates the server's hostname and performs all of the necessary actions to apply this change throughout the system. You can use this utility to change the server's hostname during a process that requires you to call the binary (for example, automated cloning processes).
Important:
- 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 uniquely identifies the server (for example,
hostname.example.com
orhostname.example.co.uk
). - Do not choose a hostname that a cPanel account on your server will use.
- Do not choose a potential proxy subdomain as a hostname (for example,
cpanel.example.com
orwhm.example.com
). - Do not select a socially-unacceptable hostname. The hostname will appear in mail headers.
- Only use lowercase, Latin-script letters in hostnames.
Note:
You can also use the following methods to change the server's hostname:
- Enter the new hostname in the Set Up Networking section of WHM's Initial Setup Assistant interface.
- Use WHM's Change Hostname interface (WHM >> Home >> Networking Setup >> Change Hostname).
- Call WHM API 1's
sethostname
function.
If you use any of these methods, you do not need to run this utility.
The /usr/local/cpanel/bin/set_hostname
utility
To use the /usr/local/cpanel/bin/set_hostname
utility, run the following command as the root
user, where newhostname.example.com
represents your new hostname:
/usr/local/cpanel/bin/set_hostname newhostname.example.com [option]
You can specify the following option for the /usr/local/cpanel/bin/set_hostname
utility:
Option | Description |
---|---|
--help | View utility information on the command line. |
When you run this command, the set_hostname
utility performs the following actions:
- It updates the hostname in the
/etc/sysconfig/network
file, and in the kernel. - It updates the domain.
- It updates the server's Apache® configuration.
- It updates the cPanel license.
- It updates cPHulk.
- It restarts MySQL®.
- It rebuilds cPanel & WHM's global cache.
- It updates the FTP, Exim, Dovecot®, and cPanel SSL certificates.
Example
To change the server's hostname to hostname.example.com
, run the following command:
/usr/local/cpanel/bin/set_hostname hostname.example.com
If the update succeeds, the utility produces the following output:
Changing hostname to hostname.example.com...Success! Hostname set to: hostname.example.com Output during rename: Altered hostname in /etc/sysconfig/network Stopping MySQL during hostname change Changing hostname in kernel to hostname.example.com Updating Apache configuration Updating cPanel license...Done. Update succeeded. Building global cache for cpanel...Done Self Signed SSL Certificate for ftp does not match current hostname! ([oldhostname.example.com] != hostname.example.com). Creating new Certificate and Key for ftp....Done Self Signed SSL Certificate for exim does not match current hostname! ([oldhostname.example.com] != hostname.example.com). Creating new Certificate and Key for exim....Done Self Signed SSL Certificate for dovecot does not match current hostname! ([oldhostname.example.com] != hostname.example.com). Creating new Certificate and Key for dovecot....Done Self Signed SSL Certificate for cpanel does not match current hostname! ([oldhostname.example.com] != hostname.example.com). Creating new Certificate and Key for cpanel....Done Updating cPHulkd hulkdsetup: database schema is up to date. Waiting for "mysql" to start ......waiting for "mysql" to initialize ...... ...finished. Startup Log Starting MySQL...[ OK ] Log Messages 150123 9:53:45 [Note] /usr/sbin/mysqld: ready for connections. 150123 09:53:43 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql 150122 22:36:53 mysqld_safe mysqld from pid file /var/lib/mysql/hostname.example.com.pid ended 150122 22:36:53 [Note] /usr/sbin/mysqld: Shutdown complete 150122 22:36:51 [Note] /usr/sbin/mysqld: Normal shutdown 150122 22:29:00 [Note] /usr/sbin/mysqld: ready for connections. 150122 22:28:59 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql 150122 22:28:58 mysqld_safe mysqld from pid file /var/lib/mysql/hostname.example.com.pid ended 150122 22:28:58 [Note] /usr/sbin/mysqld: Shutdown complete 150122 22:28:57 [Note] /usr/sbin/mysqld: Normal shutdown 150122 22:28:44 [Note] /usr/sbin/mysqld: ready for connections. 150122 22:28:43 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql 150122 22:28:42 mysqld_safe mysqld from pid file /var/lib/mysql/hostname.example.com.pid ended 150122 22:28:42 [Note] /usr/sbin/mysqld: Shutdown complete 150122 22:28:41 [Note] /usr/sbin/mysqld: Normal shutdown 150122 22:27:38 [Note] /usr/sbin/mysqld: ready for connections. 150122 22:27:37 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql 150122 22:27:36 mysqld_safe mysqld from pid file /var/lib/mysql/hostname.example.com.pid ended 150122 22:27:36 [Note] /usr/sbin/mysqld: Shutdown complete 150122 22:27:34 [Note] /usr/sbin/mysqld: Normal shutdown 150122 22:23:19 [Note] /usr/sbin/mysqld: ready for connections. 150122 22:23:18 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql 150122 22:23:17 mysqld_safe mysqld from pid file /var/lib/mysql/hostname.example.com.pid ended 150122 22:23:17 [Note] /usr/sbin/mysqld: Shutdown complete mysql started successfully.
Additional documentation
There is no content with the specified labels