Install SSL Certificate on Linux Ubuntu/VPS/Nginx

  1. add repository to system.
sudo add-apt-repository ppa:certbot/certbot
  1. updating apt.
sudo apt update
  1. installing certbot
sudo apt-get install python-certbot-apache
// or
sudo apt-get install python-certbot-nginx
  1. installing SSL by certbot
sudo certbot --nginx -d domainname.com -d www.domainname.com
  1. (Optional) we need to set auto renew the sertificates by crontab -e
sudo crontab -e
// and add this code deep below: (this will be executed everyday at 1 a.m.)
1 1 * * * certbot renew --post-hook "service nginx restart"

References :