Sometimes, there is a need to uninstall/remove Nginx from our system which is already running well. There are reasons to do this, such as: application changes, platform change and so on. But clearly it is done as our user’s request. In this article, we will discuss the easy and safe way how to uninstall Nginx from CentOS 7 system.
There are three steps that must be done to uninstall Nginx from our system, namely: stop Nginx service, remove files and uninstall NginX. For details we will discuss in detail below.
The first step before we are going to uninstall/remove our NginX is to verify the NginX services in our system, is it running or already stopped. (I use the root user for this action, but we can freely user any other user who has sudoer privilege)
[root@localhost nginx]systemctl status nginx ● nginx.service - The nginx HTTP and reverse proxy server Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled) Active: active (running) since Wed 2019-11-06 17:24:26 WIB; 14min ago Process: 4594 ExecReload=/bin/kill -s HUP $MAINPID (code=exited, status=0/SUCCESS) Process: 1430 ExecStart=/usr/sbin/nginx (code=exited, status=0/SUCCESS) Process: 1335 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=0/SUCCESS) Process: 1315 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS) Main PID: 1446 (nginx) Tasks: 5 CGroup: /system.slice/nginx.service ├─1446 nginx: master process /usr/sbin/nginx ├─4597 nginx: worker process ├─4598 nginx: worker process ├─4599 nginx: worker process └─4600 nginx: worker process
Stoping the Nginx services but using the command :
[ramans@localhost ~]$ sudo systemctl stop nginx.service
The Active status has been changed to be inactive (dead) as shown below.
The activities here will delete all Nginx files included engine (binary files), configuration files and also jpg files.
[ramans@localhost ~]$ sudo systemctl disable nginx.service [ramans@localhost ~]$ sudo rm -rf /etc/nginx [ramans@localhost ~]$ sudo rm -rf /var/log/nginx [ramans@localhost ~]$ sudo rm -rf /var/cache/nginx/ [ramans@localhost ~]$ sudo rm -rf /usr/lib/systemd/system/nginx.service
The final steps is to remove nginx form our CentOS 7.
[ramans@localhost ~] sudo yum remove nginx
Have a nice day… !