To completely remove NGINX and Let's Encrypt (Certbot) from your Ubuntu server, you'll need to perform a series of steps to ensure that all files, configurations, and dependencies are properly removed.
Here's how to do it:
Before you remove NGINX, make sure it's stopped and disabled:
sudo systemctl stop nginx
sudo systemctl disable nginx
You can uninstall NGINX and its associated packages using apt
:
sudo apt-get purge nginx nginx-common nginx-full nginx-core nginx-doc
This will remove NGINX and its common configuration files. To make sure you also remove any unused dependencies:
sudo apt-get autoremove
Additionally, you can clean up residual configuration files:
sudo apt-get autoclean
Even after removing the NGINX packages, some configuration files may still remain in /etc/nginx
and log files in /var/log/nginx
. Delete these manually:
sudo rm -rf /etc/nginx
sudo rm -rf /var/log/nginx
If you've used Certbot (Let's Encrypt) to manage SSL certificates, you'll need to uninstall it as well.
First, remove Certbot:
sudo apt-get purge certbot python3-certbot-nginx
Then remove any remaining unused dependencies:
sudo apt-get autoremove
Let's Encrypt stores its certificates and related files under /etc/letsencrypt
. To delete the certificates and all associated data:
sudo rm -rf /etc/letsencrypt
Additionally, you can delete logs from Let's Encrypt:
sudo rm -rf /var/log/letsencrypt
If you set up Certbot for automatic certificate renewal using cron jobs, check if they still exist and remove them.
- To remove any Certbot-related cron jobs:
sudo crontab -e
Look for lines related to Certbot and remove them.
Alternatively, if you set up a systemd timer for automatic renewal, you can disable and remove it:
sudo systemctl stop certbot.timer
sudo systemctl disable certbot.timer
You can run the following commands to remove any remaining orphaned packages or dependencies:
sudo apt-get autoremove --purge
sudo apt-get clean
You can run dpkg
to check if there are any remaining NGINX or Certbot-related packages:
dpkg -l | grep -i nginx
dpkg -l | grep -i certbot