Tuesday, March 30, 2021

[How To] Install Free SSL Certificate for WordPress

In this tutorial, I have installed a free SSL certificate from Let's Encrypt using the Certbot tool on Google Cloud Platform VM running Debian OS that hosts a WordPress site using Apache server. You can follow similar steps for other Cloud providers / OS distributions / CMS vendors / Web servers.

Part-1: Configure Virtual Host for your domain on Apache

cd /var/www/html

wp option update home 'https://example.com'

wp option update siteurl 'https://example.com'

sudo nano /etc/apache2/sites-available/example.com.conf

sudo apache2ctl configtest

sudo a2ensite example.com

sudo systemctl reload apache2

Part-2: Remove Certbot if previously installed (Optional)

sudo apt remove certbot

sudo sed -i '/certbot-auto/d' /etc/crontab

sudo rm -rf /opt/eff.org

sudo snap remove certbot

sudo apt autoremove

Part-3: Install Certbot

sudo apt update

sudo apt upgrade

sudo apt install snapd

sudo snap install core

sudo snap refresh core

sudo snap install --classic certbot

sudo ln -s /snap/bin/certbot /usr/bin/certbot

Part-4: Install SSL Certificates

sudo certbot --apache -d example.com -d www.example.com

sudo certbot renew --dry-run

crontab -e

sudo ls -l /etc/letsencrypt/live/

Content of example.com.conf:

<VirtualHost *:80>

ServerName example.com

ServerAlias www.example.com

ServerAdmin webmaster@localhost

DocumentRoot /var/www/html

<Directory /var/www/html>

Options -Indexes +FollowSymLinks

AllowOverride All


ErrorLog ${APACHE_LOG_DIR}/error.log

CustomLog ${APACHE_LOG_DIR}/access.log combined


No comments:

Post a Comment

Note: Only a member of this blog may post a comment.