How to Setup Free SSL Certificate for WordPress on Google Cloud (Bitnami)

1 0
Read Time:5 Minute, 20 Second

Setup Free SSL Certificate on Google Cloud (Bitnami)

In this quick-start tutorial you will learn how to configure free, auto-renewing SSL certificates for WordPress websites that are hosted on Google Cloud Platform compute engine using the Bitnami version of WordPress on Google Cloud Platform.

Before getting started with this tutorial, you should have already:

  1. Installed WordPress on Google Cloud.
  2. Configure A Domain for WordPress on Google Cloud.

There are 8 steps in this tutorial:

  1. Connect to WordPress via SSH.
  2. Install CertBot Client.
  3. Generate Certificates.
  4. Test Certificate Renewal.
  5. Setup Auto-Renewal.
  6. Configure the Certificates.
  7. Update Domain URLs.
  8. Restart your Apache Server & Hide Bitnami Logo

So let’s get started…

 

1. Connect to WordPress via SSH

SSL Certificate Setup
Go to your Google Compute homepage and click the hamburger menu in the upper left-hand corner. 

 

ssl certificate setup
Go to your Compute Engine, then to VM-instances to access your WordPress installation. 

 

ssl certificate setup
Once inside your Compute Engine, click on the SSH button to connect to your WordPress installation.

2. Install CertBot Client

ssl certificate setup
Now that you’ve connected to your website’s Apache server, you are going to execute the command to install the Certbot client. The Certbot client is used to issue the SSL certificates that will be used later on in this tutorial.
Code –
wget https://dl.eff.org/certbot-auto && chmod a+x certbot-auto

After executing each of these commands, you can either stay in the same SSH window or exit and open a new one.

3. Generate Certificates

ssl certificate setup

In this step you are going to execute the command below in order to tell the Certbot client to create SSL certificates for your website. Remember to replace dofollowbacklinks.org with your own domain name.

Code –
./certbot-auto certonly –webroot -w /opt/bitnami/apps/wordpress/htdocs/ -d YourDomainName.com -d www.YourDomainName.com
ssl certificate setup
If show this, then press 1 and Enter. Otherwise Skip this.

 

ssl certificate setup
After entering these commands, your certificates will be generated. Take note of the directory where your certificates are installed. If Not Show, Don’t Worry it will be show after done next Step.


4. Test Certificate Renewal

ssl certificate setup
Before setting up auto-renewal for your certificates, you are first going to execute the commands below in order to test the auto-renewal function.
Code –
./certbot-auto renew –dry-run
ssl certificate setup
If you get a success message, it means that the certificates are renewing properly.


5. Setup Auto-Renewal

ssl certificate setup
In order to program your certificates to automatically renew themselves, you need to configure a crontab that will automatically renew the SSL certificates before they expire.
Code –
sudo crontab -e
ssl certificate setup
After entering the crontab -e command, choose the text editor to use to create the crontab. Nano (1) is the easiest text editor to use.

 

ssl certificate setup
Now that you’ve created a new crontab file, scroll to the bottom and paste the commands listed below. The command will tell Certbot to check for renewals twice per day.
Code – 
0 0 * * * ./certbot-auto renew –quiet –no-self-upgrade
0 12 * * * ./certbot-auto renew –quiet –no-self-upgrade

After adding this code, enter ctrl+o to save changes, followed by ctrl+x to exit back to your home screen.

 

6. Configure the Certificates

ssl certificate setup
The next step is to configure your certificates. First, execute the command below to open your bitnami.conf file for editing.
Code – 
sudo nano /opt/bitnami/apache2/conf/bitnami/bitnami.conf
ssl certificate setupssl certificate setup
Next, paste the following 3-lines of code below the DocumentRoot line of the bitnami.conf file. This will tell the server to always serve your website’s pages with HTTPS encryption. Remember to replace 1pagezen.com with your own domain name. (Update 03/08/2018: ‘permanent’ added to code to mark redirect as a 301 instead of 302).
Code – 
ServerName www.YourDoainName.com
ServerAlias YourDoainName.com
Redirect permanent / https://YourDoainName.com/
ssl certificate setup
Next, use the down-arrow key to scroll down the page. Place a # sign next to each of the two placeholder certificates, and paste the path to your three SSL certificate files as shown in the command below, making sure to replace YourDoainName.com with your own domain name.
Code – 
SSLCertificateFile “/etc/letsencrypt/live/YourDoainName.com/cert.pem”
SSLCertificateKeyFile “/etc/letsencrypt/live/YourDoainName.com/privkey.pem”
SSLCertificateChainFile “/etc/letsencrypt/live/YourDoainName.com/chain.pem”

After adding this code, enter ctrl+o to save changes, followed by ctrl+x to exit back to your home screen.

 

7. Update Domain URLs

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

ssl certificate setup
In order to open your wp-config.php file for editing,
run the command below.
Code – 
sudo nano /opt/bitnami/apps/wordpress/htdocs/wp-config.php
ssl certificate setup
Inside of your wp-config.php file, you will need to replace your SiteURL and HomeURL definitions as shown below.
REPLACE THIS:

define(‘WP_HOME’,’http://YourDoainName.com’);
define(‘WP_SITEURL’,’http://YourDoainName.com’);

WITH:

define(‘WP_HOME’,’https://YourDoainName.com’);
define(‘WP_SITEURL’,’https://YourDoainName.com’);

OR

REPLACE THIS:

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

WITH:

define(‘WP_HOME’,’https://YourDoainName.com’);
define(‘WP_SITEURL’,’https://YourDoainName.com’);

8. Restart your Apache Server & Hide Bitnami Logo

ssl certificate setup
In order for your certificate changes to take effect, you need to restart you Apache server by entering the command below.
Code – 
sudo /opt/bitnami/ctlscript.sh restart apache
LOGO Hide Code –
sudo /opt/bitnami/apps/wordpress/bnconfig –disable_banner 1

That’s it!

YouTube Video

 

Previous Setup

1. Installed WordPress on Google Cloud.
How to Build Free WordPress Hosting on Google cloud

 

2. Configure A Domain for WordPress on Google Cloud.
How To Configure A Domain for WordPress on Google Cloud
Happy
Happy
0 %
Sad
Sad
0 %
Excited
Excited
0 %
Sleepy
Sleepy
0 %
Angry
Angry
0 %
Surprise
Surprise
0 %

Leave a Reply

Your email address will not be published. Required fields are marked *