First you need install Homebrew.(macOs only for this article)
brew install certbot
sudo certbot certonly --manual --preferred-challenges http -m yourmail@gmail.com -d yourdomain.com
After you store file to your server containing specific data, then you’ll receive a message as follow:
Successfully received certificate.
Certificate is saved at: /etc/letsencrypt/live/yourdomain.com/fullchain.pem
Key is saved at: /etc/letsencrypt/live/yourdomain.com/privkey.pem
This certificate expires on 2023-03-28.
These files will be updated when the certificate renews.
Then get your ssl certificate.
sudo cat /etc/letsencrypt/live/yourdomain.com/privkey.pem
sudo cat /etc/letsencrypt/live/yourdomain.com/cert.pem
sudo cat /etc/letsencrypt/live/yourdomain.com/chain.pem