January 26, 2022
How to install NginX on Ubuntu 18.04

How to Unistall Nginx from Centos 7

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. For Nginx installation on CentOS 8 tutorial can be found on How To Install Nginx on CentOS 8 article.

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.

  1. Stop Nginx Services
  2. Remove Nginx Files
  3. Uninstall Nginx

Stop Nginx Services

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
unsinstall nginx from centos 7 | show status

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.

unsinstall nginx from centos 7 | stop services

Remove Nginx files

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

Uninstall Nginx

The final steps is to remove nginx form our CentOS 7.

[ramans@localhost ~] sudo yum remove nginx
unsinstall nginx from centos 7 | remove software nginx

Have a nice day… !

Share this article via :

One thought on “How to Unistall Nginx from Centos 7

Leave a Reply

Your email address will not be published. Required fields are marked *