This KB helps user to change hostname on CentOS. By default your server will be installed with the server's given name as the hostname. Some Control Panel software such as CPanel, DirecAdmin require a valid Fully Qualified Domain Name or FQDN for the hostname to be used during their Licensing verification system.
Here are the steps user can take to change the hostname
1. Open the /etc/sysconfig/network file with your favorite text editor i.e. vi, nano. Modify the HOSTNAME= value to match your FQDN host name.
# sudo nano /etc/sysconfig/network
Edit the file with the hostname you would like to add. For example here hostname is myserver.domain.com
HOSTNAME=myserver.domain.com2. Change the host file.
Change the host that is associated to your main IPaddress for your server, file path is /etc/hosts.
file looks like below:
127.0.0.1 localhost localhost.localdomain
192.168.1.27 hostname.domain.com hostname
3. Run Hostname
The 'hostname' command on the command line and it will let you change the hostname on the server. Keep in mind that it will not actively update all programs that are running under the old hostname.
#hostname hostname.domain.com
#hostname
hostname.domain.com
#
4. Restart networking
Now after making all the necessary changes, user needs to restart networking on the server to make sure that changes are implemented:
# /etc/init.d/network restartNow you are done.