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 nginxDisable the NGINX service (so it doesn’t start on boot):
sudo systemctl disable nginxRemove NGINX and its dependencies: Run the following command to remove the NGINX package:
sudo apt-get purge nginx nginx-common nginx-full nginx-coreRemove any unused dependencies: After removing NGINX, you can clean up any unused packages:
sudo apt-get autoremoveDelete 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/nginxCheck if NGINX is completely removed: You can check if NGINX is still installed by typing:
which nginxIf nothing is returned, NGINX is successfully uninstalled.
For CentOS/RHEL-based systems:#
Stop the NGINX service:
sudo systemctl stop nginxDisable NGINX from starting at boot:
sudo systemctl disable nginxRemove the NGINX package: Run the following command to remove NGINX:
sudo yum remove nginxClean up unused dependencies: You can remove unused dependencies with:
sudo yum autoremoveRemove 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/nginxVerify removal: To confirm NGINX is uninstalled, check:
which nginxIf nothing is returned, it means NGINX is successfully uninstalled.
For Arch Linux:#
Stop the NGINX service:
sudo systemctl stop nginxDisable the NGINX service:
sudo systemctl disable nginxUninstall NGINX:
sudo pacman -Rns nginxRemove configuration and log files (optional):
sudo rm -rf /etc/nginx /var/log/nginx /var/cache/nginxVerify the removal: Check that NGINX is removed by:
which nginx
By following these steps, you will have completely uninstalled NGINX from your system.