Latest news about Bitcoin and all cryptocurrencies. Your daily crypto news habit.
I guess many of you are already using cloud based hosting solutions with WHM (cPanel) setup to provide web hosting solutions to customers or for your own projects to host websites and applications.
In many cases I use DigitalOcean for my hosting needs, But I noticed a weird issue while I working with Google Cloud Engine that I didn’t catch when working with DigitalOcean droplets (Later found out, this is common issue for few more cloud based hosting solutions as well). Which is, hostnames configured on the command line not remain through a reboot.
The issue, in detail.
Most cloud hosting providers configure automated deployments by calling a dhclient script when booting, But this generates the server’s hostname incorrectly. To overcome this issue most hosting providers are using a additional script as a workaround such as google_set_hostname on Google Cloud Engine. This is OK in many cases, but the above mentioned problem arise when some services like WHM/cPanel are using dhclient script to set machine’s hostname (WHM > Home > Networking Setup > Change Hostname) on the go. This may drives to a “Invalid” cPanel licence error as well in some cases.
The solution number:Â ONE.
If you were using:
sudo hostname hostname.example.com
Instead use:
sudo hostnamectl set-hostname hostname.example.com
In many cases this will fix the issue. But if that’s not helping, I have found another solution for you.
The solution number:Â TWO.
If the first option didn’t worked out for you, You can set a “exit” hook script which will set the hostname properly at boot-time. Remember to replace hostname.example.com with your own hostname.
mkdir -p /etc/dhcp/dhclient-exit-hooks.d/ && echo -ne '#!/bin/sh\nhostname hostname.example.com\n/scripts/fixetchosts\n' > /etc/dhcp/dhclient-exit-hooks.d/set-hostname.sh && chmod +x /etc/dhcp/dhclient-exit-hooks.d/set-hostname.sh
This script will create a script named set-hostname.sh in the /etc/dhcp/dhclient-exit-hooks.d/ directory with required permissions to run.
Follow me on: Medium Minuwan Deshapriya, Twitter @twitminu or Facebook @minuwan.
Google Cloud Engine + cPanel: Set Hostname (Workaround) was originally published in Hacker Noon on Medium, where people are continuing the conversation by highlighting and responding to this story.
Disclaimer
The views and opinions expressed in this article are solely those of the authors and do not reflect the views of Bitcoin Insider. Every investment and trading move involves risk - this is especially true for cryptocurrencies given their volatility. We strongly advise our readers to conduct their own research when making a decision.