If you have a website on VM instances on Google Cloud Platform and you desire to add a free SSL certification which will auto update every 3 month you can follow this instruction :

  1.  Open Google Cloud Paltform
  2. Select proper project, which your website is on that
  3. Click on VM instances
  4. Click on you website’s VM
  5. Click on Edit
  6. Check following items in Firewalls section
    • Allow HTTP traffic
    • Allow HTTPS traffic
  7. Click on Save ( On bottom of the page )
  8.  Return to VM instances again
  9. Click on SSH ( right side of website’s VM )
  10. Take a backup from your Apache Configuration Files
    • $ mkdir /tmp/apache_config_backup/
    • $ cp -r /etc/apache2/* /tmp/apache_config_backup/
  11. Enter Following command in Terminal
    • lsb_release -a
  12. In Description Distributor ID and version is so important ( exp : Description: Debian GNU/Linux 9.12 (stretch))
  13. Open https://certbot.eff.org/ on other browser’s tab
  14. “In My HTTP website is running  ………… on ………..”, select your “Software” ( exp : for WordPress Website is Apache ) and select your “System” (exp : for example in line 12 is Debian 9 ( stretch ) )
  15. From the below this selection select “default tab”
  16. Copy “number 2. ” command in your VM’s Terminal to install certbot client ( exp :  $  sudo apt-get install certbot python-certbot-apache )
  17. Press “y” and “Enter” to continue
  18. Copy “number 3. ” command in your VM’s Terminal to issue certificate ( exp : $ sudo certbot –apache )
  19. When Asked, enter your email address ( exp : call@w3site.ca )
  20. Press “a” and “enter” to agree and proceed
  21. Press “n” and “Enter” for sharing email address by certbot
  22. Enter your Domain name you need SSL for that ( exp : w3site.ca www.w3site.ca ) “Put space between subdomains”
  23. Press the number related to correct Server Name
  24. Select 1 or 2 for configuring redirect http traffic to https ( exp : 2 )
  25. To test Automatic renewal or re issuing certificat enter following command in the VM’s Terminal
    • sudo certbot renew –dry-run
  26. If you have WordPress :
    • Open WordPress and change http to https in settings – > general 
    • Open settings -> Permanlinks in WordPress and press save
    • Connect through SFTP ( Fillezilla ) to Server and Add following 3 lines of code to .htaccess
      1. RewriteEngine On
      2. RewriteCond %{HTTPS} off
      3. RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    • Install Better Search Replace Plugin
    • Take Backup from DB ( website/phpmyadmin ) ” DB’s User / Pass in wp-config.php”
    • replace all http://yourdomain.com to https://yourdomain.com

Congratulations !

Done !