Nginx is a popular load balancer used in many web servers to manage websites and web application. Besides that, it is also used as a mail proxy, reverse proxy, and HTTP Cache.
At times, you’d have to uninstall this useful web server. When you get to that stage, you might be wondering how to remove Nginx on your Linux system. If you happen to be using Vesta Control Panel, then this article is for you. Learn how to remove Nginx on Linux using VestaCP.
For RHEL/CentOS
If you’re using RHEL (Red Hat Enterprise Linux) or CentOS as your operating system, then below are the steps you need to follow:
Stop the running Nginx service by running this command -
Next, remove the Nginx package using this command -
In the next step, you need to make changes to the Vesta configuration. So execute the following commands:
Run the following commands to change httpd configuration:
As the final step, rebuild the vhost configs using this command - # for user in $(v-list-sys-users plain); do v-rebuild-web-domains $user; done
For Debian/Ubuntu
If you’re using a Debian or Ubuntu OS for running your systems, follow these steps:
Stop Nginx service using this command -
Remove the installed Nginx package using this command -
Run the below commands to change Vesta configuration:
Change httpd config using the below commands:
Lastly, rebuild vhost configuration using this command - # for user in $(v-list-sys-users plain); do v-rebuild-web-domains $user; done
These steps will remove teh Nginx web server from your Linux server.
Nginx Errors While Removing
When running the removal process, you might come across some errors. Especially when you execute this command, you’ll notice an error - bash vst-install.sh
The error message will be -
As and when you get this error, you can remove Nginx using the commands mentioned below:
Once Nginx along with its config files are removed, use either of the following:
Use -f flag mentioned as directed by the installer
Using a stock OS image, rebuild the droplet from the Vesta Control Panel.
But it’s highly recommended that you start from a clean server rather than cleaning it or removing packages. If you face further difficulty while removing Nginx, contact your hosting provider.
At times, you’d have to uninstall this useful web server. When you get to that stage, you might be wondering how to remove Nginx on your Linux system. If you happen to be using Vesta Control Panel, then this article is for you. Learn how to remove Nginx on Linux using VestaCP.
For RHEL/CentOS
If you’re using RHEL (Red Hat Enterprise Linux) or CentOS as your operating system, then below are the steps you need to follow:
Stop the running Nginx service by running this command -
Code:
# service nginx stop
Code:
# yum remove nginx
Code:
# cd /usr/local/vesta/conf
# sed -i “/PROXY_*/d” vesta.conf
# sed -i “s/8080/80/” vesta.conf
# sed -i “s/8443/443/” vesta.conf
Code:
# cd /etc/httpd/conf.d
# sed -i “s/8080/80/” *.conf
# sed -i “s/8443/443/” *.conf
For Debian/Ubuntu
If you’re using a Debian or Ubuntu OS for running your systems, follow these steps:
Stop Nginx service using this command -
Code:
# service nginx stop
Code:
# apt-get remove nginx
Code:
# cd /usr/local/vesta/conf
# sed -i “/PROXY_*/d” vesta.conf
# sed -i “s/8080/80/” vesta.conf
# sed -i “s/8443/443/” vesta.conf
Code:
# cd /etc/apache2/conf.d
# sed -i “s/8080/80/” *.conf
# sed -i “s/8443/443/” *.conf
These steps will remove teh Nginx web server from your Linux server.
Nginx Errors While Removing
When running the removal process, you might come across some errors. Especially when you execute this command, you’ll notice an error - bash vst-install.sh
The error message will be -
Code:
“Following packages are already installed:
nginx
It is highly recommended to remove them before proceeding.
If you want to force installation run this script with -f option:
Example: bash vst-install-ubuntu.sh –force”
Code:
sudo apt-get remove nginx
sudo apt-get purge nginx
sudo apt-get autoremove
Use -f flag mentioned as directed by the installer
Using a stock OS image, rebuild the droplet from the Vesta Control Panel.
But it’s highly recommended that you start from a clean server rather than cleaning it or removing packages. If you face further difficulty while removing Nginx, contact your hosting provider.