Change hostname, rebuild httpd

inomi13

Verified User
Joined
Jan 7, 2022
Messages
162
I would like to change hostname but I’m looking for the best practice because when I have tried to change hostname httpd was stopped and I had to rebuild httpd on custombuild. This situation is normal ?

For example, I have admin who has domain example.com, I’m adding subdomain server.example.com then I have to extension ssl to subdomain then I need to change hostname in admin settings and finally I rebuild httpd so after these operations, will I need to make something else ?
 
This situation is normal
No requirement of rebuilding httpd is not normal.

However, when changing hostname it can be that it will not be created in /etc/virtual so you have to doublecheck that.
Ask a new SSL certificate for the new hostname. Mostly it's better not to change the hostname and server.example.com is a good hostname so I wonder why you have to change that so much, we only do that when we move servers.

Anyway. Check this post for instructions. It's for when installing a new server, but all this is best changed if you change hostname too.
 
How I can change hostname via SSH because in production server when I'm changing hostname DA doesn't restart and still works old hostname but in field hostname is new value.
 
I did as you said me and in /etc/host I have new hostname. In Directadmin Admin Settings-> Server's Hostname I have also new hostname but Directadmin still works in old hostname.

In /etc/virtual I have directory with name new hostname.

Reboot server and DA don't resolve the problem, DA works only old url.
 
Last edited:
Check your /etc/hostname file that it contains the correct hostname. This will not fix things but should be correct anyway.

Very odd that DA is still using the old hostname.

- Did you change your ip's rDNs/PTR record to the new hostname?
- Did you remove the old hostname from DNS administration?
- Also check /var/named (or /etc/bind) that the new hostname record does exist there.
- Check directadmin.conf that the correct servername= setting is in there.
- Just to be sure, rebuild configs:
Code:
cd /usr/local/directadmin/custombuild
./build update
./build rewrite_confs

By the way, how do you see DA is still using the old hostname? Be aware that a DNS change for hostname can take some time before it's synchronised in DNS.
 
In /var/named is record example.com.

In /usr/local/directadmin/conf/directadmin.conf I see two possitions force_hostname and ssl_redirect_host where is name old hostname. New hostname in only postion servername.
 
In /var/named is record example.com.
That is odd. Because if you created a new hostname record like I stated in my manual and you're using the example.com domain too on the server, then in /var/named there should be both a record example.com and a record server.example.com so both domain name and a hostname record.

I see two possitions force_hostname and ssl_redirect_host
Remove those 2 lines and restart directadmin. Or manually change them to the new hostname and restart DA, these are manually added so they won't change automatically. This most likely is the reason that you still see the old hostname.
I would not use the ssl_redirect_host untill the new hostname is resolved and you created an ssl record for your new hostname.
 
Back
Top