Simply Fast WordPress [13] - Using KUSANAGI - Adding Always-On SSL and HTTP2 (Part 1. Let's Encrypt)

Enabling Let's Encrypt and Always-On SSL on an existing WordPress environment.

You might want to switch to Always-On SSL on your existing WordPress environment. It will require some proficiency, but can be done with the approach below.

(1) WordPress installed with HTTPS

Use the following command to switch KUSANAGI from the default self-certification to Let's Encrypt.

kusanagi ssl --email xxx@example.com

Because Let's Encrypt's validation method uses the HTTP protocol for access, it's necessary for the document route to be accessible via HTTP. In other words, you need to temporarily change the setting that redirects HTTP to HTTPS.

The following command will complete the Always-On SSL setup.

kusanagi ssl --https redirect --hsts weak --auto on

(2) WordPress installed with HTTP

We need to fix the HTTP URLs in the files and WordPress database.

We need to change all of the instances of "http://xxx.example.com" in the files and the database to "https://xxx.example.com".

To replace specific pleces in the database, we will use the wp command (wp-cli). For the files we will use find and grep. For example, to fix the database, navigate to the directory that WordPress is installed in, and use the command below.

wp search-replace 'http://xxx.example.com' 'https://xxx.example.com'

Similarly, running the following command in the WordPress install directory will find text pertaining to your HTTP URL.

find ./ -name '*.php' | xargs grep 'http://xxx.example.com'

Please bear in mind that places that rely on external services need to be taken care of separately. For example, a Facebook 'Like' counter can't be edited (it will be reset). You will need to edit HTTP links to external resources individually.

As with method (1), the process will be completed with this command:

kusanagi ssl --https redirect --hsts weak --auto on

Next time, we will show the significance of using Always-On SSL and HTTP/2 for business SSL certificates, and explain how to set them up. Stay tuned!