Warning: session_start(): open(/var/cpanel/php/sessions/alt-php74/sess_bde4632a5095c2724c21b2a436809442, O_RDWR) failed: No such file or directory (2) in /home/xsofthost/public_html/help/wp-content/plugins/accelerated-mobile-pages/includes/redirect.php on line 358

Warning: session_start(): Failed to read session data: files (path: /var/cpanel/php/sessions/alt-php74) in /home/xsofthost/public_html/help/wp-content/plugins/accelerated-mobile-pages/includes/redirect.php on line 358
How To Change Server Hostname In Centos and Hostname Naming Rules

How to change Server Hostname In Centos

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

				
			
then you have to change HOSTNAME= value to your FQDN hostname for example:
				
					HOSTNAME=yourserver.mydomain.com

				
			
Now you need to change the Hostname in the file hosts ,that file used for internal network mapping IPs by running the command
				
					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
				
			
Now you can run the hostname command. This command change the hostname on the server that the command line remembers, but it does not actively update all programs that are running under the old hostname.
				
					hostname yourserver.mydomain.com
hostname
yourserver.mydomain.com
				
			
Also you need to restart networking on your server to check that changes will persist on restart.
				
					/etc/init.d/network restart
				
			
Share on facebook
Share on twitter
Share on linkedin
Share on telegram
Share on whatsapp

Related Posts