I recently decided to transfer this blog from a local host managed by c panel to google cloud. I did not have any issues with my current host I just wanted to perform A/B tests and see which platform performs better.
I have been using my current host for the past 3 yrs for a variety of projects and I must commend them for having affordable hosting products and exemplary customer service. I won’t mention them since this is not an advertising feature.
Deploying on google cloud

if your deploying a new WordPress site on GCP this is the simplest and most straightforward step. you will just need to specify the deployment name, zone, machine type configuration, boot disk options, and deploy
go to marketplace on the sidebar menu➡search for WordPress➡click deploy➡enter deployment details➡deploy.
the zone and machine type you choose will affect the price of your deployment and in my case, this is what I have chosen.

I know this is expensive but since am running this deployment for three months using free Google cloud credits then why not.in google cloud, you can either run your WordPress site on compute engine which I am on app engine flexible, or GKE for heavy sites. the GKE and app engine methods are slightly advanced so it’s advisable to start with compute engine.
Migrating a site to google cloud

if you are migrating a site from one host to another as I was this is where things get a little complicated. the first step was simple but the complexity of this step almost made me give up on the whole thing. first, I did a full backup of my site using all-in-one WP migration plugin. I installed the plugin on the new site on compute engine and this is when I noticed a problem. the maximum upload size on the new site was 2MB yet my backup file was almost 1GB in size.
when faced with this problem you will need to upgrade the max upload size from the default size of 2Mb to a size greater than your backup.alot of advice I found online was either outdated or didn’t give me super user access to access the php.ini file where changes are supposed to be made.
if you are new to the CLI check this article on the Linux CLI commands for cloud architects and engineers
changing the wp. config file no longer works so don’t waste your time trying it. three files need to be updated to increase the size of the upload and this is according to PHP documentation. Most of the articles I read online insist on only changing the upload_max_filesize which doesn’t work.
post_max_size, upload_max_filesize, memory_limit
when editing the memory limit should have the largest value followed by the post max size and then the upload limit. all these values should be greater than the backup file size.
increasing the size of uploads on WordPress

after your WordPress has been installed you will need to SSH into the instance to be able to edit the PHP.ini file.
sudo apt-get upgrade
this command updates all currently installed packages
sudo vi /etc/php/8.0/apache2/php.ini
this command opens the Vim editor and the php.ini file as a super user. edit the PHP version depending on your current version of PHP. Check on your deployment details to see what PHP version you are currently running.

this command will open the php.ini which looks like the above photo. Press? to open a search box at the bottom of the file. make sure to edit the 3 files that I have mentioned above. To edit press i and after changing the values to desired ones press ESC.
saving this document is simple but if you don’t follow instructions you will get stuck on this step.
to save the changes scroll to the bottom of the document and press : this will open a blinking line of code and type w and press enter. to exit this document and return to the secure shell press: type x then enter.
sudo service apache2 restart
this command will restart & update the settings on the web server.
migrating your site to google cloud

for migration you can either use file zilla SFTP or use the all-in-one wp migration plugin which I did in my case. after following the above instructions my upload capacity on my WordPress install increased and I went to the new WordPress install and imported the backup file to my new site.
after completing I had successfully transferred my site to google cloud.
pointing your site to Google cloud

when you create a compute engine VM an external IP is issued for the VM the IP is ephemeral in nature meaning you will need to reserve it if you intend to keep it. head over VPC networks➡ ip address➡ external IP addresses ➡locate your VM➡ reserve.
next, search for cloud DNS and create a zone. the zone should have the reserved IP address. Create an A record in the same zone by adding a standard the A record should point to the VM-reserved IP address.
for your domain to point to google cloud you will need to replace your custom nameservers with the Google ones. the google name servers are located at the top right after clicking the registrar setup button on Cloud DNS.
to reduce the time for propagation reduce the TTL on the added A record to your desired time.
since I had already set up CDN and had a functioning SSL certificate I did not do the same for this project if you, however, have a new installation and need to take advantage of cloud CDN, SSL, and load balancing read my previous article on the cloud resume challenge where I did that.
why did I migrate to Google Cloud
why did I go through all this hassle of transferring my site from my host to google cloud?
- Google gave me free credits as I have said before of all the public clouds GCP is the most generous .with $300 in free credits I am able to test various projects as I would in a production setting without worrying about cost.
- One of the main reasons I did the transfer was to test various machine types and series that I couldn’t do before.
- To Take advantage of VPS hosting which is faster as compared to shared hosting that my site ran on before.
- access to logs and charts like CPU utilization, network traffic, disk throughput, memory utilization, and much more. this information is abstracted on Cpanel.
- Take advantage of Google’s global infrastructure in terms of security, networking & storage, and much more.
- through this migration have also learned how to build a cloud hosting business on the cloud which has been the most fun.