Linux徹底卸載Nginx


本機環境:centos7使用yum安裝的Nginx


1.首先輸入命令 ps -ef | grep nginx檢查一下nginx服務是否在運行。

[root@localhost /]# ps -ef |grep nginx
root       3163   2643  0 14:08 tty1     00:00:00 man nginx
root       5427      1  0 14:50 ?        00:00:00 nginx: master process nginx
nginx      5428   5427  0 14:50 ?        00:00:00 nginx: worker process
root       5532   2746  0 14:52 pts/0    00:00:00 grep --color=auto nginx

2.停止Nginx服務

[root@localhost /]# /usr/sbin/nginx -s stop
[root@localhost /]# netstat -lntp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:111             0.0.0.0:*               LISTEN      1/systemd           
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1261/sshd           
tcp6       0      0 :::111                  :::*                    LISTEN      1/systemd           
tcp6       0      0 :::22                   :::*                    LISTEN      1261/sshd

3.查找、刪除Nginx相關文件

  • 查看Nginx相關文件:whereis nginx
  • [root@localhost /]# whereis nginx
    nginx: /usr/sbin/nginx /usr/lib64/nginx /etc/nginx /usr/share/nginx /usr/share/man/man8/nginx.8.gz /usr/share/man/man3/nginx.3pm.gz
    find查找相關文件
    
    [root@localhost /]# find / -name nginx
    /usr/lib64/perl5/vendor_perl/auto/nginx
    /usr/lib64/nginx
    /usr/share/nginx
    /usr/sbin/nginx
    /etc/logrotate.d/nginx
    /etc/nginx
    /var/lib/nginx
    /var/log/nginx

     

  • 依次刪除find查找到的所有目錄:rm -rf /usr/sbin/nginx

4.再使用yum清理

[root@localhost /]# yum remove nginx
依賴關系解決

======================================================================================================
 Package                              架構            版本                       源              大小
======================================================================================================
正在刪除:
 nginx                                x86_64          1:1.12.2-3.el7             @epel          1.5 M
為依賴而移除:
 nginx-all-modules                    noarch          1:1.12.2-3.el7             @epel          0.0  
 nginx-mod-http-geoip                 x86_64          1:1.12.2-3.el7             @epel           21 k
 nginx-mod-http-image-filter          x86_64          1:1.12.2-3.el7             @epel           24 k
 nginx-mod-http-perl                  x86_64          1:1.12.2-3.el7             @epel           54 k
 nginx-mod-http-xslt-filter           x86_64          1:1.12.2-3.el7             @epel           24 k
 nginx-mod-mail                       x86_64          1:1.12.2-3.el7             @epel           99 k
 nginx-mod-stream                     x86_64          1:1.12.2-3.el7             @epel          157 k

事務概要
======================================================================================================
移除  1 軟件包 (+7 依賴軟件包)

安裝大小:1.9 M
是否繼續?[y/N]:
 
  • ok nginx 卸載完成!

鏈接:https://www.jianshu.com/p/c1ce9eec5fb2


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM