📜  nginx certbot ubuntu - Shell-Bash (1)

📅  最后修改于: 2023-12-03 15:17:52.404000             🧑  作者: Mango

Nginx + Certbot on Ubuntu

Introduction

In this tutorial, we will cover how to install and configure Nginx and Certbot on Ubuntu server. Nginx is a high-performance web server that can also act as a reverse proxy and load balancer. Certbot is a free, open-source software tool that automates the process of obtaining TLS/SSL certificates from Let’s Encrypt.

Prerequisites

You need to have a server running Ubuntu OS and root access to it.

Steps
  1. Update the system with the following command:
    sudo apt update && sudo apt upgrade -y
    
  2. Install Nginx with the following command:
    sudo apt install nginx -y
    
  3. Check the status of the Nginx service with the following command:
    systemctl status nginx
    
  4. Allow HTTP traffic through the server firewall:
    sudo ufw allow 'Nginx HTTP'
    
  5. Install Certbot with the following command:
    sudo apt install certbot python3-certbot-nginx -y
    
  6. Obtain a certificate with the following command:
    sudo certbot --nginx -d example.com -d www.example.com
    
    Note: Replace example.com and www.example.com with your own domain name.
  7. Certbot will prompt you to enter an email address and agree to the Let’s Encrypt terms of service. After that, it will contact the Let’s Encrypt server and obtain a certificate.
  8. Certbot will automatically configure Nginx to use the new certificate. You can verify this by running the following command:
    sudo nginx -t
    
  9. Reload Nginx with the following command:
    sudo service nginx reload
    
Conclusion

In this tutorial, we have installed and configured Nginx and Certbot on Ubuntu server. This enables us to secure our website with TLS/SSL encryption, ensuring the privacy and security of our users.