---
title: "How to Install Certbot with Nginx on Linux"
date: 2020-11-09T15:19:40.000Z
author: Z.SHINCHVEN
tags: [certbot, Let's Encrypt, SSL, Ubuntu, CentOS, Nginx]
canonical: https://atlassc.net/2020/11/10/install-certbot
---
[Certbot](https://certbot.eff.org/) is a handy command-line tool for [Let's Encrypt](https://letsencrypt.org/), enabling you to `set up` and `update` SSL certificates effortlessly via straightforward commands.

Though the official guide suggests using snapd for installation, I find using the built-in package manager of each Linux distribution to be simpler.

So, let's get started...

## Installation on Ubuntu 20.04 / 22.04

Refer to this guide: [Securing Nginx with Let's Encrypt on Ubuntu 20.04](https://www.digitalocean.com/community/tutorials/how-to-secure-nginx-with-let-s-encrypt-on-ubuntu-20-04)

Run this command:

```bash
sudo apt install certbot python3-certbot-nginx
```

## Installation on CentOS 7

Refer to this guide: [Securing Apache with Let's Encrypt on CentOS 7](https://www.digitalocean.com/community/tutorials/how-to-secure-apache-with-let-s-encrypt-on-centos-7)

Execute these commands:

```bash
sudo yum install epel-release
```

```bash
sudo yum install certbot python2-certbot-apache mod_ssl
```

## Setting Up Certificates

Use the command below to set up certificates for your domain.

```bash
sudo certbot --nginx
```

This command will display the list of domains on your server. Choose the one you want to secure with an SSL certificate, and the tool will handle the rest.

## Updating Certificates

Use the command below to update certificates for your domain.

```bash
## Test
sudo certbot renew --dry-run
## Update
sudo certbot renew
```

## Auto-updating Certificates

After setting up certificates, if you see a message like this:

```log
Certbot has set up a scheduled task to automatically renew this certificate in the background.
```

It means that Certbot has set up a cron job to update your certificates automatically.

[Optional] If you didn't see this message, you can set up a cron job manually to update your certificates automatically.

Run the command below to edit crontab.

```bash
sudo crontab -e
```

Add the following line to the end of the file.

```bash
0 0 1 * * certbot -q renew
```

The `-q` option is used to suppress output when running the `certbot renew` command. This means that the command will not produce any output, making it useful for automated scripts or cron jobs.
