I need to do the hostname changes on a centos server which will serve www.myserver.com
What do I need to do in /etc/hosts
, /etc/sysconfig/network
and with the hostname
command?
In /etc/sysconfig/network
do I need to write this :
HOSTNAME=www.myserver.com
or this :
HOSTNAME=myserver.com
In /etc/hosts
do I need to write this :
XXX.XXX.XXX.XXX myserver.com
or this :
XXX.XXX.XXX.XXX wwww.myserver.com www
Do I need to do sudo hostname www.myserver.com
or sudo hostname myserver.com
?
Thanks a lot!
UPDATE :
Is there something else that I need to setup about hostname?
/etc/sysconfig/network file is source from which the startup scripts take the arguments for 'hostname' command. And this should be just the machine name, not fully qualified. The domain part is usually defined in the /etc/resolv.conf file.
Assuming the fully qualified host name is 'lemon.example.com' ('www' doesn't look like a good host name to me), then:
HOSTNAME=lemon
search example.com
XXX.XXX.XXX.XXX lemon.example.com lemon
If everything is properly configured, then
hostname
command will return "lemon" andhostname -f
will return "lemon.example.com".In your case it would seem the hostname is 'www' in domain 'myserver.com'… I don't think that is exactly what you want. 'www' may be an alias (DNS CNAME)… if you want it in your /etc/hosts file, then just append it to the line with your IP:
XXX.XXX.XXX.XXX lemon.example.com lemon www.myserver.com
The settings from /etc/sysconfig/network will be applied after network is restarted. You may set the hostname immediately with the
hostname
command. /etc/hosts and /etc/resolv.conf changes are active immediately (except for applications that keep old data cached).your settings should look like this:
/etc/sysconfig/network
:HOSTNAME=www.myserver.com
/etc/hosts
:XXX.XXX.XXX.XXX wwww.myserver.com www
you can also call
hostname
, but this will only change the hostname until you restart your server the next time.as far as i can remember, these are all changes you have to make.