We are going to learn here how to change server hostname .
But first what is Server Hostname:
Every server is started with the server’s given name as the hostname. Sometimes when the server host some softwares, such as cPanel, that requires a valid Fully Qualified Domain Name (FQDN) for the hostname to be used during their licensing verification system. So its important to set the FQDN hostname for your server .
Hostname Naming Rules
Hostname can be set to any name you like, but you should keep in mind the following rules:
- hostnames can contain letters (from a to z) and /or digits (from 0 to 9).
- Also it can contain only the hyphen character ( – ) as a special character and /or dot special character ( . ) .
- hostnames can contain a combination of all above rules but must start and end with a letter or a number , and letters are case-insensitive.
- hostnames must contain between 2 and 63 characters long.
- hostnames should be descriptive (to ease identifying the computer purpose, location, geographical area, etc on the network).
How to Change Server Hostname
To modify the hostname, we need to modify /etc/hosts file First you have to Login to your server using root username privileges and edit the file by one of your favorite editor /etc/sysconfig/network by running the following command
vi /etc/sysconfig/network
HOSTNAME=yourserver.mydomain.com
vi /etc/hosts
The new values of the content file should be
127.0.0.1 localhost localhost.localdomain
93.184.216.34 yourserver.mydomain.com yourserver
hostname yourserver.mydomain.com
hostname
yourserver.mydomain.com
/etc/init.d/network restart