digitalspeed logo

How to Enable HTTPS on your WordPress website Hosted on LightSail

Enable HTTPs on WordPress website histed on AWS LightSail instance

Enabling HTTPS on your website is crucial for ensuring the security of your website’s visitors. HTTPS is a protocol that encrypts the data that is sent and received between your website and your visitors’ browsers. This prevents hackers from intercepting or tampering with information, such as passwords, credit card numbers, or personal details.

A non-secure website has an address that starts with http, such as http://example.com, while a secure website has an address that starts with https, such as https://example.com.

HTTPS also improves your website’s ranking on search engines, search engines like Google, and Bing favors websites that use HTTPS over HTTP as websites that use HTTPS are more secure and less likely to be used for fraudulent websites.

In this blog post, I will show you how to enable HTTPS on your WordPress website hosted on Amazon Lightsail, a cloud computing service that offers easy and affordable virtual servers tailored for hosting WordPress.

In the procedures below you will connect to your Lightsail instance using an SSH tunnel, you will learn how to use the Bitnami HTTPS configuration tool (bncert) to request and install a free SSL/TLS certificate from Let’s Encrypt. You will also learn how to configure your website to automatically redirect visitors from HTTP to HTTPS so that they always use a secure connection.

If you follow these steps in this blog post diligently you would have a website that uses HTTPS and you can confirm this if you see a padlock icon in the address bar of your browser, meaning your website is secure and verified. This will not only boost your website’s credibility and reputation but also protect your visitors’ privacy and data.

Complete the prerequisites.

Before following the steps that are listed below to enable HTTPS on your WordPress website, it is supposed that you have done the following.

  1. Created a WordPress instance in Lightsail, and configured your WordPress website on your instance. If you haven’t done so check out the Lightsail documentation below.  Get started with Linux/Unix-based instances in Amazon Lightsail.
  2. Attached a static IP to your instance. This is needed so your instance will always be accessed through a specific IP address, it will remain static and won’t change often. See the Lightsail documentation below on how to do that.  Create a static IP and attach it to an instance in Amazon Lightsail.
  3. Create a snapshot of your WordPress instance after you’re done configuring it or enabling automatic snapshots. A snapshot can be used as a backup from which you can create another instance in case something goes wrong with your original instance while you’re modifying it. See the Lightsail documentation below on how to create snapshots on Lightsail.  Creating a snapshot of your Linux or Unix instance in Amazon Lightsail.
  4. Added DNS records to the DNS of your domain that direct traffic for the apex of your domain and for its www subdomain to the assigned static public IP address of your WordPress instance in Lightsail. See the Lightsail documentation below on how to do that –  DNS in Amazon Lightsail.

Enable HTTPS on your WordPress instance in Amazon Lightsail

To enable HTTPS for your Lightsail instance, connect to your Lightsail instance using SSH, and use the bncert tool to request an SSL/TLS certificate from the Let’s Encrypt certificate authority, let’s Encrypt is a certificate authority that provides certificates for websites, This tool lets you request certificates only for the domains and subdomains that you specify when making your request. This is done usually after verifying that you own the domain.

After your certificate is validated, you can then configure your WordPress website to automatically redirect visitors from HTTP to HTTPS as an example http://example.com redirects to https://example.com so that visitors are forced to use the encrypted connection.

Bncert is not preinstalled on all Certified by Bitnami WordPress instances when they’re created, continue with the steps to enable HTTPS for Lightsail.

Steps

  1. Sign in to the Lightsail console.
  2. On the Lightsail home page, choose the SSH quick connect icon for your WordPress instance.

    Amazon Lightsail WordPress ssh quick connect
    Amazon Lightsail WordPress ssh quick connect
  3. Enter the following command to run the bncert tool.

    sudo /opt/bitnami/bncert-tool

    if you see command not found in the response as shown in the following example, then the bncert tool is not installed on your instance. Continue to the next step in this procedure to install the bncert tool on your instance.

    If you see Welcome to the Bitnami HTTPS configuration tool in the response as shown in the image below, then the bncert tool is installed on your instance. Skip Steps 5 to 9 and Continue to Step 10.

    Run bncert tool success
    Bncert tool is running successfully
  4. Enter the following command to download the bncert run the file to your instance.

    wget -O bncert-linux-x64.run https://downloads.bitnami.com/files/bncert/latest/bncert-linux-x64.run
  5. Enter the following command to create a directory for the bncert run a file on your instance.
    sudo mkdir /opt/bitnami/bncert
  6. Enter the following command to move the downloaded bncert run the file to the new directory you created. sudo mv bncert-linux-x64.run /opt/bitnami/bncert/
  7. Enter the following command to make the bncert run a file that can be executed as a program.
    sudo chmod +x /opt/bitnami/bncert/bncert-linux-x64.run
  8. Enter the following command to create a symbolic link that runs the bncert tool when you enter the 
    sudo /opt/bitnami/bncert-tool command.
    sudo ln -s /opt/bitnami/bncert/bncert-linux-x64.run /opt/bitnami/bncert-tool


    You are now done installing the bncert tool on your instance. Continue to the Step 10
  9. Enter the following command to run the bncert tool.

    sudo /opt/bitnami/bncert-tool

    If the bncert tool has been installed on your instance for a while, then you might see a message indicating that an updated version of the tool is available. Choose to download it as shown in the following example, and then enter the sudo /opt/bitnami/bncert-tool command to run the bncert tool again.
  10. Enter your primary domain name and alternate domain names separated by a space as shown in the following example. Ensure that your domain name is directing traffic to the IP address of your instance, this confirms that you own the domain and serves as validation for your certificate.

    bncert list domain names
    bncert list domain names for your site
  11. The bncert tool will ask you how you want your website’s redirection to be configured. These are the options available:

    Bncert enable/disable redirections
    Bncert tool enable/disable redirection


    Enable HTTP to HTTPS redirection – This specifies whether users who browse to the HTTP version of your website (i.e., http:/example.com) are automatically redirected to the HTTPS version (i.e., https://example.com). Type Y and press Enter to enable it.

    Enable non-www to www redirection – Specifies whether users who browse to the apex of your domain (i.e., https://example.com) are automatically redirected to your domain’s www subdomain (i.e., https://www.example.com). We recommend enabling this option. However, you may want to disable it and enable the alternate option (enable www to non-www redirection) if you have specified the apex of your domain as your preferred website address in search engine tools like Google’s webmaster tools, or if your apex points directly to your IP and your www subdomain references your apex via a CNAME record. Type Y and press Enter to enable it.

    Enable www to non-www redirection – Specifies whether users who browse to your domain’s www subdomain (i.e., https://www.example.com) are automatically redirected to the apex of your domain (i.e., https://example.com). We recommend disabling this, if you enabled non-www redirection to www. Type N and press Enter to disable it.
  12. The changes that are going to be made are listed. Type Y and press Enter to confirm and continue.
  13. Enter your email address to associate with your Let’s Encrypt certificate and press Enter.
  14. Review the Let’s Encrypt Subscriber Agreement. Type Y and press Enter to accept the agreement and continue.

    The actions are performed to enable HTTPS on your instance, including requesting the certificate and configuring the redirections you specified.

    Your certificate is successfully issued and validated, and the redirections are successfully configured on your instance if you see a message similar to the following example.
  15. confirm that your website is using HTTPS by browsing to all of the domains that you specified when using the bncert tool. When you visit each domain, you should see a padlock icon at the address bar where your domain is written.

Visit the Lightsail documentation: Enabling HTTPS on your WordPress instance in Amazon Lightsail to learn more

Enable HTTPS on WordPress

When you enable https for the Lightsail instance it only enforces secure connections that go through your domain name. Two major issues might still arise:

  • If your WordPress isn’t configured to use HTTPS, the page might not show all the content properly.
  • If your Lightsail instance is accessed via its IP address, the connections will remain unsecured.

There are many ways to configure your WordPress website to use HTTPS, some of the methods require that you alter the WordPress wp-config.php file while others are just button clicks.

Change your WordPress Console settings

You can make your WordPress website accessible through HTTPS from the WordPress console settings. Follow the steps below.

Steps

  1. Login to your WordPress admin console, select Settings and select General from the side menu.
  2. Edit the entries of,
    WordPress Address (URL)
    Site Address (URL)

    WordPress setting for url
    WordPress settings page for url
  3. Change both URLs to use HTTPS if it uses HTTP.
    Example
    http://example.com to https://example.com
    You can use your domain name instead of example.com but this would mean that you cannot log in to your WordPress admin console again, you would only log in to the console using your domain name.
    If you successfully changed the WordPress and Site address fields to use HTTPS then you are done with the setup. visit your website through HTTPS to confirm and you should see a padlock at the address bar.

    If you can’t modify the URL which would usually be the case then you would have to change the URL through the WordPress wp-config.php file. Go through one of the options below to change the wp-config.php file.

Check out this WordPress resources WordPress: HTTPS for WordPress – Documentation

Modify wp-config.php file

There are so many ways for you to modify wp-config.php but we will talk about two ways here, which is to modify the wp-config file from Cpanel to modify from an SSH tunnel using Vim text editor.

Steps to edit wp-config.php through SSH

  1. Sign in to the Lightsail console.
  2. On the Lightsail instance page, choose the browser-based SSH client icon to connect to your WordPress instance through SSH.
  3. After you’re connected to your instance, enter the following command to create a backup of the wp-config.php file. If something goes wrong, you can restore the file using the backup.

    sudo cp /opt/bitnami/wordpress/wp-config.php /opt/bitnami/wordpress/wp-config.php.backup
  4. Enter the following command to open the wp-config.php file using Vim.

    sudo vim /opt/bitnami/wordpress/wp-config.php
  5. Press I to enter insert mode in Vim.

    Lightsail ssh page ready to insert
    Lightsail SSH page ready to insert through Vim
  6. Scroll through the content and delete the following lines of code in the file.

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

    Lightsail SSH page ready to insert
    Lightsail SSH page showing the required code
  7. Change the lines of code to the following depending on the version of WordPress that you’re using:
    You can use example.com in the code below.

    define(‘WP_SITEURL’, ‘https://example.com’);
    define(‘WP_HOME’, ‘https://example.com’);
  8. Press the Esc key to exit insert mode in Vim, then type :wq! and press Enter to save your edits (write) and quit Vim.

    LightSail SSH page Close Vim editor
    LightSail SSH page Close Vim editor
  9. Enter the following command to restart your Lightsail instance.

    sudo /opt/bitnami/ctlscript.sh restart apache
  10. Wait a few moments for your Instance to restart, then test that your WordPress website is now accessible through HTTPS. You can now exit the SSH tunnel when you type exit
  11. If something goes wrong, re-connect to your instance using the browser-based SSH client. Run the following command to restore the wp-config.php file using the backup you created earlier in this guide.

    sudo cp /opt/bitnami/wordpress/wp-config.php.backup /opt/bitnami/wordpress/wp-config.php

If there were issues connecting to your WordPress console after you have modified the wp-config file then you can restore the backup using the command above and try the following option which worked best for me.

Check out these articles to know more about this:

Edit the wp-config file from the Cpanel

cPanel is a web-based Linux graphical interface (GUI) used as a control panel to simplify website and server management. cPanel is used to publish websites, manage domains, organize web files, create email accounts, and more.

You cannot easily access your website cPanel if your server is fully managed like on Lightsail, but it is possible to use the cPanel on Lightsail see the Lightsail documentation on how to do this.

If your server is not fully managed, an example is when you host WordPress on EC2 then you can easily access the cPanel by including a colon and 2087 to your domain name. See the example below where example.com is your domain name.

https://example.com:2087

Follow the steps below to modify the wp-config file through the cPanel.

Steps

  1. Login to your cPanel.
  2. Choose File Manager.
  3. Select the public_html folder, then the wp-config.php file.
  4. Click on the Code Editor button to edit the file.
  5. Scroll through the content and delete the following lines of code in the file.

    define(‘WP_SITEURL’, ‘http://’ . $_SERVER[‘HTTP_HOST’] . ‘/’);
    define(‘WP_HOME’, ‘http://’ . $_SERVER[‘HTTP_HOST’] . ‘/’);
  6. Change the lines of code to the following. You can use example.com in the code below or use your domain name in place of example.com.

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

Check out wpbeginner’s guide on Cpanel to know more about Cpanel.

Install Really Simple SLL, a WordPress plugin

Really Simple SSL is a lightweight standard for every WordPress website to keep SSL performance optimized and leverage heavyweight security standards.

Picture of really simple SSL

Steps

  1. Login to your WordPress dashboard.
  2. Click on Plugins, and click on Add new from the options.
  3. Search for Really Simple SSL from the search icon.
  4. Click on Install, when the plugin is installed click on Activate.

Confirm that you can now access your website properly through HTTPS.
Visit Really Simple SSL documentation to find out in case of any issues.

Check out the Bitnami discussion forum to learn more.
WordPress post Changing the site URL for more options on how to fix this issue.
Check out this article Elegantthemes:How to Redirect WordPress from HTTP to HTTPS.

Check out Forums | WordPress.org

If you intended to enable HTTPs on an Nginx server instead then follow this AWS documentation to enable HTTPS for Nginx LightSail server

Please share this article at the top of the page under the share this button. Thanks

Recent Post

Send Us A Message

Related Post

Join our newsletter to stay updated

digitalspeed-logo

At DIGITALSPEED, you can get updates, reviews and learn about new digital tools and features on existing tools. check us on social media.

Get In Touch

Lagos, Nigeria

DIGITALSPEED © All Rights Reserved.

2025

Scroll to Top

Seach for Articles