Start by enabling the Certbot repository:
sudo add-apt-repository ppa:certbot/certbot
Next, update the package list:
sudo apt update
Next, install the Certbot Apache package:
sudo apt install python-certbot-apache
Finally, obtain the SSL certificate:
sudo certbot --apache -d example.com
Should you need to get certificates for multiple domains, simply add as follows:
-d domain1.com -d domain2.com
Note that the installed Certbot package adds a renew script to /etc/cron.d which will automatically take care of certificate renewal. This script runs twice daily.
To renew certificates manually you can run either of the following:
certbot certonly --webroot -w /var/www/html -d yourdomain.com
or
certbot --apache -d yourdomain.com