I thought I'd start this HOW-TO for changing the CPanel hostname. Please let me have your input and maybe we can make this thread a 'definitive' HOW-TO.
-----------------------------
1. Change Hostname In WHM
Select Change Hostname from the Server Setup section on the menu to the left.
Enter the new hostname in the box and click 'Change'. Hostnames should have two dots in them and should be setup as if they're a subdomain of your server's main domain name. So, if your server's main domain is mybox.com, your hostname could be something like server01.mybox.com.
WHM then prompts you to add an 'A Entry for your hostname' if you don't already have one (see bnext point)
2. Add an 'A' Entry
You can do this by going to the DNS Functions area of the left menu and selecting Add an A Entry for your Hostname. It will ask you to confirm the details: press Add the entry to do so.
3. Manual Checks
Now this didn't work fully when we did it, so we had to check some stuff manually (none, some or all of these may need ameding in your environment). SSH to your server and do the following:
'hosts' file
Type: pico /etc/hosts and check that the entries are as follows -
127.0.0.1 localhost
xxx.xxx.xxx.xxx server01.mybox.com server01
- replacing xxx.xxx.xxx.xxx with your server's IP address and adding your hostname after it.
Hit CTRL+X and reply 'y' to exit pico and save the file.
Apache
Type: pico /etc/httpd/conf/httpd.conf, scroll down and find the ServerName entry and make sure your fully qualified hostname (i.e. server01.mybox.com) is specified after it.
While you're there, you may want to change the ServerAdmin e-mail (just above the ServerName) too.
Hit CTRL+X and reply 'y' to exit pico and save the file.
wwwacct.conf
Type: pico /etc/wwwacct.conf, scroll down and find the HOST entry and make sure your fully qualified hostname (i.e. server01.mybox.com) is specified after it.
Hit CTRL+X and reply 'y' to exit pico and save the file.
resolv.conf
Type: pico /etc/resolv.conf, and check that the first two lines read as follows -
domain mybox.com
search mybox.com
Replacing mybox.com with your server's primary domain name and adding your own nameservers to the file.
Hit CTRL+X and reply 'y' to exit pico and save the file.
network
Type: pico /etc/sysconfig/network, and check that HOSTNAME line specifies your host name.
Hit CTRL+X and reply 'y' to exit pico and save the file.
--------------------
You may need to reboot your box to make hostname changes take effect.