| Home Register Memberlist Help Search Quick Links No Replies |
|
||||||
| Basic How-tos Help Us Noobs by Sharing Your Wisdom |
![]() |
![]() |
|
Thread Tools | ![]() |
|
#1
|
||||
|
||||
|
Existing Hostname
To see the existing hostname on a server, issue the following command: Code:
hostname _________________________________ New Hostname The hostname must be a fully qualified domain name (FQDN) with a DNS zone A record on the server. A subdomain for a domain on the server works best, since many servers will have a conflict in functionality if a domain name with a site on the server is used for the server's hostname. As such, avoid using mydomain.com and pick something like server.mydomain.com for the hostname instead. _________________________________ STEPS TO CHANGE THE HOSTNAME The following steps would be taken on systems other than cPanel. Please do not change the A Record, edit Apache, or make changes to the other files noted if using cPanel. The steps for cPanel are detailed at the bottom of this guide. Creating the A Record Zone 1. At /var/named location, either create a zone file by copying the old hostname zone file, or edit the prior hostname zone file. Change each entry for the old hostname to the new one in the file. 2. Copy /etc/named.conf: Code:
cp /etc/named.conf /etc/named.conf.bakYYMMDD 3. Edit /etc/named.conf and change the prior hostname entry to the new hostname: Code:
zone "server2.mydomain.com" {
type master;
file "/var/named/server2.mydomain.com.db";
};
Alternatively, a new entry could be placed into /etc/named.conf with the new hostname details without replacing the old hostname entry. 4. Run the command to reload the zone: Code:
rndc reload server2.mydomain.com 5. Check the new hostname is resolving for the zone: Code:
host server2.mydomain.com Code:
server2.mydomain.com has address IP# Adding the Hostname to Apache 1. Copy the Apache configuration file, which is normally at either /usr/local/apache/conf/httpd.conf or /etc/httpd/conf/httpd.conf (oftentimes, the file exists at both locations). Code:
cp /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf.bakYYMMDD 2. Edit httpd.conf file using vi with the find and replace command: Code:
Esc key, then :%s/oldhostname/newhostname/ and then Enter key 3. Restart Apache: Code:
/etc/init.d/httpd restart _________________________________ Changing Hostname on Most Systems The first file needing edited would be /etc/hosts file, which would look similar to this: Code:
IP server.mydomain.com server 127.0.0.1 localhost After editing and saving that file, then different systems have additional files to edit and/or commands to run in order to process the change. _________________________________ Individual Systems Debian 1. Edit /etc/hostname file and put only the new hostname in that file (so it would contain only server.mydomain.com if that is the new hostname). 2. Run the command: Code:
/bin/hostname -F /etc/hostname Code:
/etc/init.d/hostname.sh start FreeBSD 1. First issue the command: Code:
hostname newname Code:
hostname server2.mydomain.com 2. Edit /etc/rc.conf file for the following line: Code:
hostname="newname" RedHat / CentOS 1. First issue the command: Code:
hostname newname Code:
hostname server2.mydomain.com 2. Edit /etc/sysconfig/network file for the following line: Code:
HOSTNAME=newname cPanel cPanel servers, regardless of the operating system type, would not have any changes made to /etc/hosts or other files. Instead, use the following steps: 1. Log into WHM. 2. Click on Change Hostname and set the new hostname here. 3. Click on "Add An A Entry for your hostname" button. cPanel will change the hostname in Basic cPanel/WHM Setup in WHM, in httpd.conf file, in /etc/hosts file, and in any additional file where the hostname is set (such as /etc/sysconfig/network file on RedHat/CentOS). You will also want to update the SSL certificates for the server services in WHM's Manage Service SSL Certificates area by clicking on "Reset Certificate" link for each. Please note that the /etc/hosts file will simply have the new hostname added into it. The old hostname entries will still be listed as possible names for the server, so the file might end up looking like the following: Code:
IP oldhostname.mydomain.com newhostname.mydomain.com newhostname oldhostname 127.0.0.1 localhost |
![]() |
| Bookmarks |
| Thread Tools | |
|
|
Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd. |
||