Page tree

Versions Compared

Key

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

Include Page
LIB:_Version68
LIB:_Version68

Toc no bullet

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. This utility is useful if you wish 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 these methods, you do not need to run this utility.

The set_hostname Utility

To use the /usr/local/cpanel/bin/set_hostname utility, run the following command as the root user:

Code Block
languagebash
/usr/local/cpanel/bin/set_hostname newhostname 

In this command, newhostname is the new hostname that you wish to use on the server.

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 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.
Note
titleNotes:
  • Run the /usr/local/cpanel/bin/set_hostname --help command to view utility information on the command line.
  • If you specify the server's existing hostname when you run the command, the utility synchronizes the server's hostname configuration.

  • The utility returns an exit code of 0 if it succeeds, or an exit code of 1 if it fails.

 

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 succeeded, 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 ("server","hostname") and label in ("whm","cpanel") and space = currentSpace()


Localtab
titleFor cPanel users

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


Localtab
titleFor WHM users

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


Localtab
titleFor developers

Content by Label
showLabelsfalse
max5
showSpacefalse
cqllabel in ("server","hostname") and space = "DD"