# Install SSL Certificate on Linux Ubuntu/VPS/Nginx

1. add repository to system.
    

```bash
sudo add-apt-repository ppa:certbot/certbot
```

1. updating apt.
    

```bash
sudo apt update
```

1. installing certbot
    

```bash
sudo apt-get install python-certbot-apache
// or
sudo apt-get install python-certbot-nginx
```

1. installing SSL by certbot
    

```bash
sudo certbot --nginx -d domainname.com -d www.domainname.com
```

1. `(Optional)` we need to set auto renew the sertificates by crontab -e
    

```bash
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 :

* [https://www.domainesia.com/panduan/cara-install-lets-encrypt-di-vps/#Nginx](https://s.id/1FGPX)
    
* [https://www.onepagezen.com/letsencrypt-auto-renew-certbot-apache/](https://s.id/1FGQ3)
