Child pages
  • The set_hostname Utility

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents
stylenone

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).

Multiexcerpt include
MultiExcerptNameHostnameWarning
PageWithExcerptChange Hostname

Note
titleNote:

You can also use the following methods to change the server's hostname:

If you use either 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:

Code Block
languagebash
/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:

OptionDescription
--helpView 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:

Code Block
languagebash
/usr/local/cpanel/bin/set_hostname hostname.example.com

If the update succeeds, the utility produces the following output:

Code Block
languagebash
linenumberstrue
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

Localtab Group


Localtab
activetrue
titleSuggested documentation

Content by Label
showLabelsfalse
max5
showSpacefalse
cqllabel in ("hostname") and label in ("whm") and space = currentSpace()


Localtab
titleFor cPanel users

Content by Label
showLabelsfalse
max5
showSpacefalse
cqllabel in ("hostname") and label = "cpanel" and space = currentSpace()


Localtab
titleFor WHM users

Content by Label
showLabelsfalse
max5
showSpacefalse
cqllabel in ("hostname") and label = "whm" and space in (currentSpace(),"CKB")


Localtab
titleFor developers

Content by Label
showLabelsfalse
max5
showSpacefalse
cqllabel = "hostname" and space = "DD"