How to completely uninstall NGINX
To completely uninstall NGINX from your system, follow the appropriate instructions based on your operating system:
For Ubuntu/Debian-based systems:#
Stop the NGINX service:
sudo systemctl stop nginx
Disable the NGINX service (so it doesn’t start on boot):
sudo systemctl disable nginx
Remove NGINX and its dependencies: Run the following command to remove the NGINX package:
sudo apt-get purge nginx nginx-common nginx-full nginx-core
Remove any unused dependencies: After removing NGINX, you can clean up any unused packages:
sudo apt-get autoremove
Delete configuration and log files (optional): If you want to remove all configuration and log files (warning: this deletes custom configurations), use:
sudo rm -rf /etc/nginx /var/log/nginx /var/cache/nginx
Check if NGINX is completely removed: You can check if NGINX is still installed by typing:
which nginx
If nothing is returned, NGINX is successfully uninstalled.
For CentOS/RHEL-based systems:#
Stop the NGINX service:
sudo systemctl stop nginx
Disable NGINX from starting at boot:
sudo systemctl disable nginx
Remove the NGINX package: Run the following command to remove NGINX:
sudo yum remove nginx
Clean up unused dependencies: You can remove unused dependencies with:
sudo yum autoremove
Remove configuration and log files (optional): If you want to remove the configuration files and logs, use:
sudo rm -rf /etc/nginx /var/log/nginx /var/cache/nginx
Verify removal: To confirm NGINX is uninstalled, check:
which nginx
If nothing is returned, it means NGINX is successfully uninstalled.
For Arch Linux:#
Stop the NGINX service:
sudo systemctl stop nginx
Disable the NGINX service:
sudo systemctl disable nginx
Uninstall NGINX:
sudo pacman -Rns nginx
Remove configuration and log files (optional):
sudo rm -rf /etc/nginx /var/log/nginx /var/cache/nginx
Verify the removal: Check that NGINX is removed by:
which nginx
By following these steps, you will have completely uninstalled NGINX from your system.