Step 5 – Enable HTTPS for WordPress

It is always recommended to enable the HTTPS on WordPress website to encrypt the HTTP traffic. You will need to install and configure Let’s Encrypt free SSL to enable the HTTPS.

First, install the Let’s Encrypt client package using the following command:

apt-get install certbot python3-certbot-apache -y

Now, run the following command to download and install the Let’s Encrypt certificate on your WordPress website.

certbot --apache --agree-tos --redirect --hsts --uir --staple-ocsp --email [email protected] -d yourdomain.com,www.yourdomain.com

This command will download the Let’s Encrypt SSL and configure your Apache to use those SSL certificates.

A brief explanation of each option is shown below:

  • –apache: Let’s Encrypt Apache plugin.
  • –agree-tos: Agree to terms and services.
  • –redirect: Redirect website to HTTPS using 301 redirect.
  • –hsts: Enable Strict-Transport-Security header to every HTTP response.
  • –uir: Add the Content-Security-Policy header to every HTTP response.
  • –staple-ocsp: Enables OCSP Stapling.
  • –email: A valid email address used for registration and certificate notification.
  • -d: Define domain name.

Next, you will need to set up a cron job to renew the Let’s Encrypt certificate automatically. To do so edit the cron job with the following command:

crontab -e

Add the following line:

@daily certbot renew --quiet && systemctl reload apache2

Save and close the file when you are finished. The above cron job will run daily and automatically renew the SSL certificates if they are about to expire.

Categories: Uncategorized

0 Comments

Leave a Reply

Avatar placeholder

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