我要评分
获取效率
正确性
完整性
易理解

Uninstalling Nginx

Generally, you do not need to uninstall Nginx when the service is running. Before uninstalling Nginx, ensure that the Nginx service has been stopped. Select an uninstallation method based on the installation mode.

Stopping Nginx

The following describes three methods for stoping Nginx: Use the script command, use the process end command, or stop Nginx as a service.

  • Method 1: Use a script to stop Nginx.
    1
    /usr/local/nginx/sbin/nginx -s quit
    

    For Nginx 1.14.2 or Nginx 1.19.3 installed using the mirror site RPM package on CentOS 7.6 or CentOS 8.1, run the following command to stop Nginx:

    /usr/sbin/nginx -s quit
  • Method 2: Use a process to stop Nginx.
    1
    pkill nginx
    
  • Method 3: Stop Nginx as a service.
    1
    service nginx stop
    

Uninstalling Nginx (Installed Using the Source Code or the One-Click Script)

During source code compilation and installation of Nginx, only the corresponding files are generated. Therefore, you can directly delete the corresponding directories.
1
2
rm -rf /usr/local/nginx
ls /usr/local/nginx

Uninstalling Nginx (Installed Using the Mirror Site RPM Package)

  1. Uninstall Nginx.
    1
    2
    rpm -qa | grep nginx
    rpm -e --nodeps nginx-x.xx.x
    
  2. Query whether the software package installed in the system contains the Nginx software.
    1
    rpm -qa | grep nginx
    

    If the Nginx software cannot be found, the uninstallation is complete.

  3. Delete the Nginx installation directory.

    For Nginx installed using the mirror site RPM package on CentOS 7.6 or CentOS 8.1, replace /usr/local/nginx in the following command with /etc/nginx.

    1
    2
    rm -rf /usr/local/nginx
    ls /usr/local/nginx