Categories: Tech Tips

Migrate WordPress – Amazon AWS EC2 to Google Compute Engine

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
      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 :
      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: -> FAQ section

    8. To enable Varnish cache, use the steps mentioned here:

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. ( 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/ 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.

Disqus Comments Loading...
Published by
Anil Gupta

Recent Posts

HR 392 – Removing the country limit for US green cards

The HR 392 has been merged into an amendment attached to a spending bill, H.R.6776 (DHS Appropriations Act) for 2019.…

3 months ago

Travel while H1B is pending with USCIS – Extension, Transfer, COS, Amendment

Travelling while H1B Change of status is pending You can but should NOT travel outside USA while your H1B COS…

3 weeks ago

H4 EAD News 2018 DHS – USCIS Plan Removal by Nov

Nov 16, 2018 - DHS may publish rule by Nov 2018 H4 EAD news update today: DHS publishes mid-year agenda…

6 months ago

US Visa Dropbox eligibility checker India 2018

Am I eligible for US Visa DropBox in 2018? Check your eligibility using this simple question and answer form (you…

3 months ago

Does buying house on H1B Visa in USA make sense?

Should I buy home without worrying about the un-certainty attached to H1B visa? Buying house on H1B visa is a…

4 months ago

Renew Indian passport in USA with CKGS by post

Indian passport renewal USA, Documents list, NRI online application form. CKGS Processing time 1-4 weeks, 3 photo. No police verification.…

4 years ago