How to change hostname on CentOS permanently

If you are installing LAMP on a new server and ran into the following issue with httpd during the startup:

httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName

or

httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain for ServerName

you need to change it to make your server identifiable on the network. Hostname is the name that server calls itself i.e. it could be cp.yourdomain.com or mail.yourdomain2.com

In order to change hostname on your CentOS server permanently follow these steps
1. At your domain registrar level assign new host record to your server's IP address
2. Make sure you have nano installed

yum install nano

3. Edit network configuration file while logged in as root

nano /etc/sysconfig/network

4. It will open file with the content like below:

NETWORKING=yes
HOSTNAME=localhost.localdomain
GATEWAY=123.234.123.234

5. Change the HOSTNAME to the name that you've assigned at your domain registrar level
6. Hit Ctrl-X to exit and save changes
7. Reboot your server for changes to take effect
  • 1 Users Found This Useful
Was this answer helpful?

Related Articles

FFMPEG install on CentOS

How to install FFMPEG and FFMPEG-PHP install on CentOS 5.X To install FFMPEG please follow the...

How to set hostname on Centos 6?

In order to permanently set hostname on Centos 6 VPS you neew to run # nano...

CentOS: Start custom script automatically after network startup

Find the ifup-post under /etc/sysconfig/network-scripts. This scipt is called right after any...

Change hostname in CentOS

How to Change Hostname - CentOSThis KB helps user to change hostname on CentOS. By default your...

How to add a new user to CentOS

Open a terminal window and log in to your server via SSH.Create the user by entering the...