Migrate WordPress – Amazon AWS EC2 to Google Compute Engine

Anil Gupta  9 Jun, 18      11  Tech Tips

Technology that we are going to use

  1. Google Compute Engine VM – This is same as Amazon AWS EC2
  2. Google Domains – For website domain and DNS. You can use any domain registrar like Godaddy or anyone that your domain is already registered with.
  3. WP Super Cache Plugin Settings

Step by step process to move from Amazon AWS to Google Compute Engine

    1. WordPress back Up
      1. Use ‘WP All in One Migration’ plugin to get a back for your wordpress.
      2. Save the back up as a file on local machine. Please note that if your back up file is larger than 512 MB, the free version will not support it.In that case, you can choose to exclude the wp-content folder all-together. This will certainly bring down the total file size by at-least 70%. WP-Content folder can be copied separately to new server easily with using this plugin.
    2. Install Bitnami Image on Google Compute Engine VM
      1. Create account on Google CLoud console or log in to your account, if you already have one.
      2. Create a project, add billing and then use Bitnami WordPress Image to launch the installer.
      3. After couple of minutes, you should have your wordpress blog ready to go. Google assigns it a default External IP address (They call it ‘Ephemeral IP’).
    3. Connect to Google VM using Putty or WinSCP client
      1. Create Private Key File using PuttyGen.
      2. Add this private key to google’s VM instance.
      3. Then, use this private key in Winscp to connect to VM instance.
    4. Things to do after bitnami wordpress install
      1. Remove bitnami banner: Get into machine SSH (Easiest way is to use Google Clound console login)
        Run this command:
        sudo /opt/bitnami/apps/wordpress/bnconfig --disable_banner 1
      2. Change website domain name using this help
        https://docs.bitnami.com/google/apps/wordpress/#how-to-change-the-wordpress-domain-name
      3. To change the wp-config file
        Run this command to give permissions to user bitnami:
        sudo chown bitnami:daemon /opt/bitnami/apps/wordpress/htdocs/wp-config.php
        Log in with user ‘bitnami’ using WinSCP, then open file and make changes to local file. Save.
    5. Set Up WP Super Cache
      1. Add mod_rewrite rules
        Use this link :https://docs.bitnami.com/google/apps/wordpress/#using-modrewrite-caching
      2. Set up ‘Browser Caching’
        Open /opt/bitnami/apps/wordpress/conf/htaccess.conf file.
        Add the following rules at the end of file.# BEGIN EXPIRESExpiresActive On
        ExpiresDefault "access plus 10 days"
        ExpiresByType text/css "access plus 1 week"
        ExpiresByType text/plain "access plus 1 month"
        ExpiresByType image/svg+xml "access 1 month"
        ExpiresByType image/gif "access plus 1 month"
        ExpiresByType image/png "access plus 1 month"
        ExpiresByType image/jpeg "access plus 1 month"
        ExpiresByType application/x-javascript "access plus 1 month"
        ExpiresByType application/javascript "access plus 1 week"
        ExpiresByType application/x-icon "access plus 1 year"# END EXPIRES
      3. Then, use this private key in Winscp to connect to VM instance.
    6. Editing or adding files to wp-content or theme folder.
      For security reasons, these folders have the daemon:daemon permissions.
      What you can do is connect via ssh and then execute these commands.

      sudo chown bitnami:daemon -R /opt/bitnami/apps/wordpress/htdocs/wp-content/themes

      Add the files you require, and then make sure you revert it back
      sudo chown daemon:daemon -R /opt/bitnami/apps/wordpress/htdocs/wp-content/themes

    7. for Final permissions to help all plugins work correctly, execute these commands:

      sudo chown -R bitnami:daemon /opt/bitnami/apps/wordpress/htdocs/wp-content/cache

      sudo find /opt/bitnami/apps/wordpress/htdocs/wp-content/cache -type f -exec chmod 664 {} \;

      sudo find /opt/bitnami/apps/wordpress/htdocs/wp-content/cache -type d -exec chmod 775 {} \;

      sudo chown bitnami:daemon /opt/bitnami/apps/wordpress/htdocs/wp-config.php

      sudo chmod g+w /opt/bitnami/apps/wordpress/htdocs/wp-config.php

      Source: https://docs.bitnami.com/google/apps/wordpress/ -> FAQ section

    8. To enable Varnish cache, use the steps mentioned here:
      https://docs.bitnami.com/google/components/varnish/

WordPress with FREE HTTPS SSL security certificate – Good for Google SEO

Thanks to this post here that has helped me write up these steps. They are basically same. I have just added a few more details, to explain a little more wherever possible.

  1. Install plugin ‘WP Encrypt’As the instructions are quite well documented follow these instructions here.These instructions have been brought here from this Bitnami community link:

    WP Encrypt has settings to ‘Automatically update the certificate’ before it expires.
    Do check that option as the validity is just 90 days and you do not want to manually do it every time.

    Return here after generating your certificates.

    Once you have generated your certificates, follow the next steps below.

  2. Give appropriate permissions. Remember, you would have already ran these commands before you generated certificates. You need to run them again now. Here they are
    sudo chown -R bitnami:daemon /opt/bitnami/apps/wordpress/letsencrypt
    sudo find /opt/bitnami/apps/wordpress/letsencrypt -type d -exec chmod 0775 {} \;
    sudo find /opt/bitnami/apps/wordpress/letsencrypt -type f -exec chmod 0664 {} \;
  3. Rename existing files (that have been already created by bitnami ) to avoid conflict with the newly created LetsEncrypt files.
    We are going to create a link with same name to help run the commands shared by Bitnami.sudo mv /opt/bitnami/apache2/conf/server.crt /opt/bitnami/apache2/conf/server.crt.bak

    sudo mv /opt/bitnami/apache2/conf/server.key /opt/bitnami/apache2/conf/server.key.bak

  4. Link your (the one you just created using Lets Encrypt) SSL certificate and certificate key file to the correct locations (the location set up by Bitnami installer).Remember to replace the DOMAIN placeholder with your actual domain name.

    We are creating links to the files that Lets Encrypt created instead of copying them to Bitnami’s location.This is to make sure that whenever the files are updated i.e. the certificates are renewed, you do not need to manually copy the files over to Bitnami’s provided location.

    The symbolic link will take care of it automatically and will always read the correct file.
    sudo ln -s /opt/bitnami/apps/wordpress/letsencrypt/live/YOUR_DOMAIN_NAME/fullchain.pem /opt/bitnami/apache2/conf/server.crt

    sudo ln -s /opt/bitnami/apps/wordpress/letsencrypt/live/YOUR_DOMAIN_NAME/private.pem /opt/bitnami/apache2/conf/server.key

  5. Once you have copied all the server certificate files, you may make them readable by the root user only with the following commands:
    sudo chown root:root /opt/bitnami/apache2/conf/server*
    sudo chmod 600 /opt/bitnami/apache2/conf/server*
  6. Open port 443 in the server firewall.
  7. Force https redirection. (https://docs.bitnami.com/aws/apps/wordpress/#how-to-force-https-redirection)Add the following to the top of the <code>/opt/bitnami/apps/wordpress/conf/httpd-prefix.conf</code> file:
    RewriteEngine On
    RewriteCond %{HTTPS} !=on
    RewriteRule ^/(.*) https://%{SERVER_NAME}/$1 [R,L]
  8. Restart the Apache server
    sudo /opt/bitnami/ctlscript.sh restart apache
    Once re-started with no error, go to your wordpress blog and you should see all the URL’s automatically changed to include https.
    Try to explicitly go to a URL with http://YOUR_DOMAIN and it should be redirected to https version.

Use Lets Encrypt SSL certificate with Google cloud load balancer

At the time of writing this article, the certificate generated by WP Lets Encrypt was not acceptable by Google Cloud LOAD balancer. The same certificate worked on Compute engine VM directly though.

As a workaround, just for the Google Load Balancer, you generate a 2048 bit strength SSL certificate manually using these steps.

Once you have the 2048 certificates, head over to this article to set up Google Load Balancer with Google CDN.

   Read all 11 Q & A


  1. remmelkemp   28 May, 18 at 3:51 pm

    I came to this page while I was searching to transfer my wordpress blog from aws to google.
    I use amazon lightsail and pay $ 6 per month. It was working very fine until 2 weeks ago and my instance gives health check warning. I did not do any change. I contacted amazon and they are least helpful. They ask 29 dollars per month support plan to help with this.
    I have very low user blog and I am looking for a cheap hosting service. I am not sure if google is right place.
    Please help.

    • Anil Gupta   28 May, 18 at 4:09 pm

      Google Compute Engine price would probably be same as AWS depending on what configuration you choose. You can find the pricing here:
      https://cloud.google.com/compute/pricing

      • remmelkemp   28 May, 18 at 4:47 pm

        I have a very small instance. 100mb in wordpress.
        Will you please advice on how to migrate it ?

        • Anil Gupta   28 May, 18 at 4:55 pm

          I have already given all the steps to migrate in above article.
          What else are you looking for?


          • I am not a software professional, whatever I learned , I learned by myself. So please forgive my ignorance.
            I have lightsail and not EC2. Will that make any difference ? Other worry I have is – What if the problem is with the wordpress it self ? I did try deleting and reinstalling on aws but same problem persists. Amazon itself is useless in helping.


            • I am not sure what kind of issue you are facing with wordpress unless you specifically explain it.
              Health check warning are most probably about your server and NOT wordpress.


            • That helps.
              Let me explain in short.
              I have a small blog for medical professionals. http://www.criticalcareupdate.com. I created it on 1&1.com initially in 2016, and after 1 year I migrated it to amazon. Transferred domain to amazon route 53 as well.
              It worked fine for 8 months, no issues. About 3 weeks ago, it started becoming inaccessible. I deleted instance and reinstalled. Then I put health check alarm on aws along with jetpack monitor alarm. I also changed the theme.
              Every 18- 24 hours, I get healthcheck alarm as well as jetpack alarm saying site is down. I stop and restart the instance and works again for 18-24 hours.
              I contacted amazon and they have not responded for a week. Providing me stupid suggestion to increase instance size. My site has may be 5-8 visitors a day.. not big. So I do not need bigger instance.
              Not sure where the problem is.

              I think for my small needs, I can get from google for free. I read somewhere.


            • Well, I cannot comment on what’s going on with your current AWS instance. This article is about migration. If you have any questions for migration, i can help.
              For toehr questions, Amazon and their forum will be the best resource to lok out for.


            • Thanks. I will try to migrate using your excellent post. If I run into some trouble, I will contact you here. Thanks

            • remmelkemp   9 Jun, 18 at 3:48 pm

              I was able to migrate to Google with just step 1 and 2.
              Only thing extra I did was remove banner with ssh connection.
              Google bitnami dashboard gives you temp user and password to log in to new instance via wordpress. Once you migrate your old site by using wp all in migration plug in, your username password will change automatically.

            • Anil Gupta   9 Jun, 18 at 7:04 pm

              Great.