How to migrate wordpress to Google cloud

I recently decided to transfer my blog from my hosting company N6 Cloud Google Cloud. I did not have any issues with cloud hosting I just wanted to perform A/B tests and see which platform performs better.

I have been using N6 cloud for the past 3 years for a variety of projects and I must commend them for having affordable WordPress hosting products and exemplary customer service.

Deploying WordPress to Google Cloud compute engine

Deploying a new WordPress site on GCP is the 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 and the region will affect the price of your deployment. in my case, this is what I chose.

I know $60/month is expensive for a normal WordPress blog but since am running this deployment for three months using free Google Cloud credits 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 and need more setup 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 Google Cloud as I was this is where things get a little complicated. the first step of making a backup was simple but the complexity of the next 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. A lot of advice I found online was either outdated or didn’t give me super user access(sudo) to the php.ini file where changes are supposed to be made.

since you are going to be using the command line check this article on the Bash commands for cloud architects and engineers if you have little experience.

The below commands to increase the upload size of WordPress uploads will work on a Debian/Ubuntu WordPress instance deployed on any VM on the cloud or on-premises and isn’t for GCP only.

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.

you need to increase the size in these files as well: post_max_size, upload_max_filesize, and 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 in the virtual machine instance you will need to SSH into the instance to be able to edit the PHP.ini file. This step will help you increase the size of uploads of any WordPress deployment.

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 to 2GB and I proceeded to the new WordPress install and imported the backup file to my new site.

after completing this step I successfully transferred my site to Google Cloud.

changing DNS settings on 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 networksIP 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.

If you have not purchased a domain Hostinger and Namecheap have an offer for cheap domains you can’t afford to miss.

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?

  1. 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 can test various projects as I would in a production setting without worrying about cost.
  2. One of the main reasons I did the transfer was to test various machine types and series that I couldn’t do before.
  3. To Take advantage of Self-hosting with my static IP which is safer as compared to shared hosting that uses a shared IP which is never safe.
  4. access to logs and charts like CPU utilization, network traffic, disk throughput, memory utilization, and much more. this information is abstracted on Cpanel.
  5. Take advantage of Google’s global infrastructure in terms of security, networking & storage, and much more.
  6. through this migration, I have also learned how to build a cloud-hosting business on the cloud which has been the most fun.
  7. With Google Cloud, I can decide to migrate my site to a serverless App engine as it grows or also increase the machine size of my VM and add load balancing which is something I couldn’t do before.

This article contains affiliate links and I earn a commission from qualifying purchases.

Leave a Comment