Hostname On cPanel / WHM Server Resets To Project Name On Google Cloud Fix

So you made a WHM server on Google Cloud and before you get to use it suddenly its broken?  I feel your pain.  Not sure when this started but it seems Google Cloud auto writes over the hostname.  Usually not an issue but cPanel seems to rely upon this entry to the point when you type a FQDN like louisville.data502.com it changes to rubbish in a redirect and the site can’t be resolved.

cPanel Has A Fix.

You can see it from their site or I have the steps below.

To configure VPS deployments, many cloud hosting providers use the dhclient script, which includes the configuration of the instance’s hostname.

The dhclient script may not preserve the locally-configured hostname, so hosting providers use scripts to work around this issue. For example, Google Cloud Platform Services™ uses the google_set_hostname script.

The workaround scripts may interfere with WHM’s Change Hostname feature (WHM >> Home >> Networking Setup >> Change Hostname), which causes hostname configuration issues and a locked cPanel & WHM license.

The solution

To resolve this issue, you must create a dhclient exit hook script to set the hostname properly.
Create the set-hostname.sh file with the following contents in the /etc/dhcp/dhclient-exit-hooks.d/ directory, where hostname.example.com represents your server’s new hostname:

You can also create the file with the following command, where hostname.example.com represents your server’s new hostname: Note in the code below you should be sudo and hostname.example.com will need to be changed

mkdir -p /etc/dhcp/dhclient-exit-hooks.d/ && echo -ne ‘#!/bin/shnhostname hostname.example.comn/scripts/fixetchostsn’ > /etc/dhcp/dhclient-exit-hooks.d/zzz-set-hostname.sh && chmod +x /etc/dhcp/dhclient-exit-hooks.d/zzz-set-hostname.sh

OR You can make it in a drawn out 3 step process.

  1. #!/bin/sh
  2. hostname hostname.example.com
  3. /scripts/fixetchosts

That should keep the name as you intended.

And finally I want to say check out Ultimate SEO. Its a great site.

Cloudflare DNS and CDN With WordPress High Availability On Google Cloud

cloud502com
Cloud502

Key Components & Services

There are two custom services running on the deployed machines that are essential for the solution to function properly. These services are ​gcs-sync ​(running on WordPress instances – both Admin and Content) and ​cloudsql-proxy​ (running on the SQL Proxy instances).

The ​gcs-sync​ service runs a script ​/opt/c2d/downloads/gcs-sync​ that, depending on the role the VM is assigned (Content or Admin), will check in with the GCS bucket tied to the deployment and determine if content needs to be pushed to or pulled from GCS. If you need to interact with the service, you can do so via ​systemctl​. For example:

systemctl stop gcs​-​sync

will kill the script checking GCS, and the node will not receive any updates that come from the Administrator Node. Conversely, if the service needs to be started you can do so with the following command:

systemctl start gcs​-​sync

The ​cloudsql-proxy​ service makes use of the ​Cloud SQL Proxy​ binary so you can connect to your Cloud SQL instance without having to whitelist IP addresses, which can change when instances are deleted and recreated in a Managed Instance Group. The Cloud SQL binary is located at ​/opt/c2d/downloads/cloud_sql_proxy​ and the script that executes the binary is located at ​/opt/c2d/downloads/cloudsql-proxy​. Like the service that runs ​gcs-sync​, it can be interacted with using ​systemctl​. Stopping the service can be done with:

systemctl stop cloudsql​-​proxy

At this point your instance will not be able to communicate with the Cloud SQL instance, and the application will not function. If you needed to manually start the service for any reason you can do so with the following command:

systemctl start cloudsql​-​proxy

Cloudflare DNS and CDN With WordPress High Availability On Google Cloud

The post Cloudflare DNS and CDN With WordPress High Availability On Google Cloud appeared first on Cloud502.
Cloud502 – Cloud502 Cloud based Data, Analytics, SEO and Hosting Solutions. Cloud502 offers data insights in Louisville, KY.

https://www.cloud502.com/cloudflare-dns-and-cdn-with-wordpress-high-availability-on-google-cloud/