Installing cPanel & WHM on Google Cloud
Installing cPanel & WHM on your Google Cloud Instance could overwhelm you if you are not familiar with the installation & configuration process.
That is why In this tutorial I will help to install cPanel and WHM on your Google Compute Engine’s VM Instance in a Step-by Step manner.
Is cPanel free?
cPanel is not free. However, 15 days test licences are available for new users. You can learn more about cPanel trial licences from their official page.
How much does cPanel cost?
The cPanel pricing could vary widely, depending upon the number of accounts. For a single cPanel hosting account you will be paying $15 per month. For 5 cPanel accounts you will be paying around $20 /month. The hosting cost could get much lower if you need more than 5 accounts. For example, up to 30 accounts you will be paying $30 per month and $45/month + $0.20 for each additional account for up to 100 accounts. Here is a link of cPanel official website.
To install cPanel on your Google Cloud Instances follow the below steps,
Step 1: Creating a new VM Instance
In this step we are going to create a new CentOS 7 VM instance for cPanel & WHM installation. We are creating a new VM because cPanel recommand us to install cPanel & WHM on a freshly-installed operating system.
Log in to your Google Cloud account. On your Google Cloud dashboard and click the hamburger menu in the upper left-hand corner of the screen.
Now, Navigate to Compute Engine >> VM instances.
After that, Click on ‘Create’ to launch a new VM instance.
Name: It is your instance name. Give any name as you wise.
Region: Choose a specific geographical location, this is where google cloud going to setup your CentOS 7 server for cPanel & WHM installation. Here is a link of google cloud website for more information.
Zone: Every region on Google Cloud has one or more zones. For example, the
us-east1 region denotes a region on the east of the United States that has three zones:
Machine type: Chose a machine as per your budget or need. From the cPanel & WHM System Requirements, we know that CentOS 7 will require at least 1GB of RAM and a minimum of 20GB disk space. Here I choose n1-standard-1 which has 1 vCpu and 3.75 Gb memory(ram), you also can choose g1-small which has 0.5 vCpu and 1.7 GB ram. Here is link of google cloud website for more information.
Boot Disk: Click the Change button to select CentOS 7 system image.
Now, navigate to OS images and choose CentOS 7 from the section menu.
Boot disk type: Choose a a minimum of 20 GB disk space. Google has two type of boot disk, SSD persistent disk (SSD) and Standard persistent disk (mechanical hard disk). Because you are going to host a cPanel server, I recommand you to choose SSD.
Firewall: If you want to set up a web server, then check the boxes to allow HTTP and HTTPS traffic. It will open 80, 443 ports in google cloud firewall.
Finally, Again click the Create button, to deploy your CentOS 7 VM for cPanel & WHM installation.
Step 2: Reserving a Static IP address
By default, Google cloud VMs External IP address could change automatically. But you will need a static IP address for cPanel & WHM licence.
Before we are going to reserve a static IP address, we will test your current experimental IP address for cpanel trial licence.
First, Copy you External IP address from Google Cloud Compute engine >> VM instances section.
After that, open the Cpanel licence verification page and paste your server external IP address for verification.
If it says “not licenced” then by following the below steps reserved that IP address, but if it says “licenced” then you need a new IP address for cpanel trial licence. You can get a new experimental IP address by restarting your VM instance from your Google Cloud dashboard.
After you have successfully verified your IP address, from Google Cloud dashboard and click the hamburger menu in the upper left-hand corner of the screen. Then, navigate to Networking >> VPC network >> External IP addresses.
Now, from the type section, choose Static. After that Give a name and click on the reserve button.
Step 3: Creating a sub-domain for cPanel
In this step we are going to create a sub-domain for our cPanel & WHM installation. By doing this we can access cPanel & WHM via a domain name. You can also access your cPanel from your server IP address. Later, we will use this sub-domain as our cpanel server hostname.
Depending on your domain registrar or DNS provider, the screenshots may look different. However, the basic concept is the same.
To access my cpanel via cpanel.siteyaar.com domain-name, I need to point A name to my VM instance IP address from my DNS provider dashboard. If you are not familiar with this process then you can check this blogs.
Because I am using Cloudflare as my DNS server, I added an A name from Cloudflare DNS management section.
If you are also using Cloudflare and also want to create a subdomain as cpanel. your-domain-name.com, then navigate to DNS Management section, after that click on ‘add record’. Then choose ‘A’ from Type field. Type cpanel in the ‘Name*’ field. Paste your Google Cloud VM instance external IP address on the IPv4 address field. Lastly, press the save button to add the new A record.
- Type: As record type, choose A.
- Host: Type cpanel.
- Points to: Enter the external IP address of your Google cloud server. In this example, it is 18.104.22.168
- TTL (Time To Live): TTL value tells your browser how long a record should be stored in cached before a new copy of the record must be retrieved from DNS. Select custom or use the default one.
- Click to apply the settings.
Step 4: Configuring Firewall for cPanel
A cPanel & WHM server requires multiple ports to operate functionality. But by default, Google cloud blocks all the ports except some few ones (SSH- 22, HTTP- 80, HTTPs- 443). To open requires Ports we will modify and add some new rules in Google Cloud firewall. Here is a link of cPanel official website for more details.
Here are the ports which we are going open in Google Cloud Firewall.
- FTP: TCP : 20,21
- Email: TCP :25, 26, 110, 143, 465, 579, 993, 995 UDP: 465
- DNS: TCP: 53 UDP: 53
- cPanel: TCP: 783, 873, 2703, 2077, 2078, 2079, 2080, 2082, 2083, 2086, 2087, 2089, 2095, 2096, 2195, 6277, 24441 UDP: 783, 873, 6277, 24441
On your Google Cloud dashboard and click the hamburger menu in the upper left-hand corner of the screen. Then navigate to VPC network >> Firewall rules.
After that click on “CREATE FIREWALL RULE” button from the top section of your screen.
Give a suitable name for your new firewall rule. Because I am going to open the cPanel ports, I typed cPanel in Name field.
Now leave the “Direction of traffic” and “Action on match” on default settings.
Targets: Choose All instances in the network.
Source filter: Choose IP ranges.
Source IP ranges: Type 0.0.0.0/0
Select “Specified protocols and ports” from the protocols and ports section. After that place this ports 783, 873, 2703, 2077, 2078, 2079, 2080, 2082, 2083, 2086, 2087, 2089, 2095, 2096, 2195, 6277, 24441 on TCP field and 783, 873, 6277, 24441 in UDP field.
Lastly, click the Create button to apply the changes.
Just like the cpanel rule create a new firewall rule for email.
Just like the image above You will see a similar screen if you create a new firewall rule for FTP.
CPanel & WHM installation also came with DNS blind server that is why in the above image I am opening a port for DNS server.
The above image is a screenshot of my Google Cloud Firewall rule section. As you can see that I opened ports for cPanel, DNS, email, and ftp.
Step 5: Preparing for cPanel & WHM installation
In these steps we are going to prepare our VM instance for error free cPanel & WHM installation. We are going to do it by installing and removing some CentOS applications.
From your Google cloud dashboard, navigate to compute engine >> VM Instances. Then, Open SSH terminal by simply clicking “SSH” next to our instance details under Connect.
Once in the terminal, I was logged in as a non-root user. To change to root, use:
Now that you are root, perform a few minor updates and installs to get started:
yum update -y
yum install -y perl yum install -y wget
The Network Manager service automates the network’s settings. It also disrupts connections to the IP addresses that reside in the
ipaliases module. You have to remove Network Manager to install cPanel & WHM.
To disable Network Manager, run the following command:
yum remove NetworkManager
To access cPanel & WHM via a domain name we have to assign a hostname to the server. In the previous step we created a new subdomain, In this step we are going assign that sub domain as hostname.
Run the following command, where
cpanel.example.com represents your desired hostname:
Step 6: Installing cPanel & WHM
cPanel & WHM installation process is very simple, you just have to execute a command on your SSH terminal. That command will download and execute a cPanel & WHM installation script which automatically install and modify all necessary application and settings.
To install cPanel & WHM on your server, run the following command:
cd /home && curl -o latest -L https://securedownloads.cpanel.net/latest && sh latest
This command changes your session to the
home directory, downloads the latest version of cPanel & WHM, and runs the installation script.
It will take around 15 – 40 minutes to complete the installation. Don’t close the terminal until the setup is completed.
Step 7: Fixing Hostname issue
To configure VPS deployments, Google Cloud Platform uses the
dhclient script, which includes the configuration of the instance’s hostname.
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
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.
To solve this issue we are going to set a “exit” hook script which will set the hostname properly at boot-time.
Remember to replace cpanel.example.com with your own hostname.
mkdir -p /etc/dhcp/dhclient-exit-hooks.d/ && echo -ne '#!/bin/sh\nhostname cpanel.example.com\n/scripts/fixetchosts\n' > /etc/dhcp/dhclient-exit-hooks.d/zzz-set-hostname.sh && chmod +x /etc/dhcp/dhclient-exit-hooks.d/zzz-set-hostname.sh
Step 8: Log in to WHM
Once you have successfully installed cPanel & WHM on your Google Cloud VM instance, It is time to log in to your WHM (Web Host Manager) account.
You will need your Linux OS(s) root credential to access your WHM account.
To update or reset the root password execute the command below,
Log in to WHM.
To log in to WHM, perform the following steps:
Navigate to the following URL, where
IPADDRESSrepresents your server’s IP address and cpane.example.com your server’s hostname:
- Enter your username as root and password as root user(S) password.
- Click Log in.
Step 9: Configuring WHM
Once you successfully logged in to WHM account for first time, you have to agree to Cpanel & WHM terms to access cPanel.
After that type your Email Address on the Email address field. Cpanel will send status and minor notification to that address. After that click the Finish button.
Step 10: Log in to cPanel
To log in to cPanel, first you have to create and configure a new account from WHM dashboard.
First, click the WHM logo on your top right-hand conner. After that click the Create a new Account button to create a new cpanel account.
Now it is your time!
I tried my best to provide you a complete tutorial on how to Instal cPanel & WHM on Google Cloud Compute engine. I hope you liked it.
If you need help just drop a comment.
If you benefited from this tutorial, and would like to support my work, please like my Facebook page.
Our Latest Posts