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 :
- Â Open Google Cloud Paltform
- Select proper project, which your website is on that
- Click on VM instances
- Click on you website’s VM
- Click on Edit
- Check following items in Firewalls section
- Allow HTTP traffic
- Allow HTTPS traffic
- Click on Save ( On bottom of the page )
- Â Return to VM instances again
- Click on SSH ( right side of website’s VM )
- Take a backup from your Apache Configuration Files
- $ mkdir /tmp/apache_config_backup/
- $ cp -r /etc/apache2/* /tmp/apache_config_backup/
- Enter Following command in Terminal
- lsb_release -a
- In Description Distributor ID and version is so important ( exp : Description: Debian GNU/Linux 9.12 (stretch))
- Open https://certbot.eff.org/ on other browser’s tab
- “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 ) )
- From the below this selection select “default tab”
- Copy “number 2. ” command in your VM’s Terminal to install certbot client ( exp :Â $Â sudo apt-get install certbot python-certbot-apache )
- Press “y” and “Enter” to continue
- Copy “number 3. ” command in your VM’s Terminal to issue certificate ( exp : $ sudo certbot –apache )
- When Asked, enter your email address ( exp : call@w3site.ca )
- Press “a” and “enter” to agree and proceed
- Press “n” and “Enter” for sharing email address by certbot
- Enter your Domain name you need SSL for that ( exp : w3site.ca www.w3site.ca ) “Put space between subdomains”
- Press the number related to correct Server Name
- Select 1 or 2 for configuring redirect http traffic to https ( exp : 2 )
- To test Automatic renewal or re issuing certificat enter following command in the VM’s Terminal
- sudo certbot renew –dry-run
- 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
- RewriteEngine On
- RewriteCond %{HTTPS} off
- RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI}
- 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 !