Install FREE SSL Certificate for WordPress on Google Cloud -Bitnami. This post, provides all steps to install Let’s Encrypt Certificate for your WordPress installation on Google Cloud with Bitnami.

Not using Bitnami? Choose a different Installation:

Bitnami

Click to Deploy

Prerequisites

  1. WordPress Installation using Bitnami.
  2. Setup Google Cloud DNS for your Domain name.

Bitnami WordPress Installation

Bitnami is a packaged application provider for many platforms. The Package contents of Bitnami installation of WordPress on Google Cloud is listed below.

  • Apache webserver.
  • MySQL database.
  • PHP v7.2.
  • phpMyAdmin.
  • Varnish cache.
  • Latest WordPress.

Connect to your Instance by SSH

Once you have all the prerequisites ready, you can connect your instance and access it using SSH.

Go to your Google Cloud Console and navigate to Compute Engine >> VM Instances.

Click the SSH button that’s at the right of your VM Instance.

Now a new terminal will be opened and connected to your VM Instance.

Install CertBot

Execute the following command to install Certbot Client which is used to generate SSL certificates.

wget https://dl.eff.org/certbot-auto
chmod a+x certbot-auto

Generate SSL Certificates

To generate new SSL certificates execute the following command.

Replace yourdomainname.com with your Domain name.

./certbot-auto certonly --webroot -w /opt/bitnami/apps/wordpress/htdocs/ -d yourdomainname.com -d www.yourdomainname.com

Once you run the command, you need to enter your email address and accept the terms and conditions. Finally a set of certificated will be issued to you in this directory (/etc/letsencrypt/live/yourdomainanme.com).

Install FREE SSL Certificate

Edit your bitnami.conf file and make the folowing changes.

sudo nano /opt/bitnami/apache2/conf/bitnami/bitnami.conf

Paste the following code below the line DocumentRoot "/opt/bitnami/apache2/htdocs"

Replace yourdomainname.com with your Domain name.

ServerName www.yourdomainname.com 
ServerAlias yourdomainname .com
Redirect permanent / https://www.yourdomainname.com/

Now scroll down below and find the default directives of SSLCertificateFile and SSLCertificateKeyFile

Comment the both line s by placing a # symbol at the starting of the line.

Paste the following certificates below the two lines.

SSLCertificateFile "/etc/letsencrypt/live/yourdomainname.com/cert.pem" 
SSLCertificateKeyFile "/etc/letsencrypt/live/yourdomainname.com/privkey.pem"
SSLCertificateChainFile "/etc/letsencrypt/live/yourdomainname.com/chain.pem"

So your output will be like this.

Output

#SSLCertificateFile "/opt/bitnami/apache2/conf/server.cert"
#SSLCertificateKeyFile "/opt/bitnami/apache2/conf/server.key"
SSLCertificateFile "/etc/letsencrypt/live/yourdomainname.com/cert.pem"
SSLCertificateKeyFile "/etc/letsencrypt/live/yourdomainname.com/privkey.pem"
SSLCertificateChainFile "/etc/letsencrypt/live/yourdomainname.com/chain.pem"

Hit Ctrl+x followed by Y and Enter to save the file.

Update Domain URls

Changing your website URLs via Settings > General is disabled in the Bitnami version, so need to change your URLs by editing your wp-config.php folder.

sudo nano /opt/bitnami/apps/wordpress/htdocs/wp-config.php

Replace the URLs with the below details.

REPLACE THIS: 
define('WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST'] . '/');
define('WP_HOME', 'http://' . $_SERVER['HTTP_HOST'] . '/');

WITH:
define('WP_SITEURL', 'https://' . $_SERVER['HTTP_HOST'] . '/');
define('WP_HOME', 'https://' . $_SERVER['HTTP_HOST'] . '/');

Restart Apache server

For the changes to take effect you need to restart your Apache web server.

sudo /opt/bitnami/ctlscript.sh restart apache

Setup Auto-renewal

To setup auto-renewal for your certificate tou need to set up cronjob to check the certificate expiry and renew it automatically.

sudo mv certbot-auto /etc/letsencrypt/

Set up a cronjob.

sudo crontab -e

Choose 1 to select the nano editor.

Paste the following line to the last.

45 2 * * 6 cd /etc/letsencrypt/ && ./certbot-auto renew && /opt/bitnami/ctlscript.sh restart

Hit Ctrl+X followed by Y and Enter to install the cronjob. This setting will check every week and renew the certificate which is close to expiry.

Conclusion

Now you have learned how to install FREE SSL Certificate for your WordPress with Bitnami on Google Cloud.

Thanks for your time. If you face any problem or any feedback, please leave a comment below.

2 Comments

  1. I want to know how to install vista cpanel in google cloud.
    In vista cpanel is free?
    Please help me….

Write A Comment

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Where Writing Meets Entrepreneurship!

Get FREE Google Cloud Tutorials.
GET NOW
close-link
Please help us get 1000 likes in Facebook. Thank You!
LIKE NOW

Stay Connected!

Get latest tutorials on Google Cloud and Open Source topics
SUBSCRIBE
close-link