Introduction:
Deploying a secure NGINX web server on Ubuntu 24.04 is simple. Follow these steps to set up NGINX with a free SSL certificate from Let’s Encrypt.
Step 1: Update Your Server
Before starting, ensure your server is up to date. Run the following commands to update your package list and upgrade your installed packages:
sudo apt update && sudo apt upgrade -yStep 2: Install NGINX
Once the system is updated, install NGINX:
sudo apt install nginx -yAfter installation, start and enable NGINX to run at boot:
sudo systemctl start nginx && sudo systemctl enable nginxYou can verify that NGINX is running by visiting your server’s IP address in a browser.
Step 3: Install Certbot and Obtain an SSL Certificate
Now, install Certbot and the NGINX plugin to automate the SSL certificate installation:
sudo apt install certbot python3-certbot-nginx -yNext, obtain the SSL certificate for your domain:
sudo certbot --nginx -d yourdomain.com -d www.yourdomain.comFollow the prompts to agree to the terms of service and select whether to redirect HTTP to HTTPS (choose ‘redirect’ to force HTTPS).
Step 4: Set Up Automatic Certificate Renewal
Let’s Encrypt certificates expire every 90 days. To ensure your SSL certificate renews automatically, set up a cron job:
sudo systemctl enable certbot.timerThis command ensures Certbot will automatically check and renew the certificate before expiration.
Done!
Congratulations! You’ve successfully deployed NGINX with a Let’s Encrypt SSL certificate on Ubuntu 24.04. Your server is now secure and ready for traffic. Regular updates and SSL certificate renewals will keep your web server safe and stable.