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.
- For source code compilation installation or one-click script installation, delete the installation directory when uninstalling Nginx. For details, see Uninstalling Nginx (Installed Using the Source Code or the One-Click Script).
- For mirror site RPM package installation, query and uninstall related packages before uninstalling Nginx, and then delete the installation directory. For details, see Uninstalling Nginx (Installed Using the Mirror Site RPM Package).
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.
1pkill nginx - Method 3: Stop Nginx as a service.
1service 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)
- Uninstall Nginx.
1 2
rpm -qa | grep nginx rpm -e --nodeps nginx-x.xx.x
- Query whether the software package installed in the system contains the Nginx software.
1rpm -qa | grep nginx
If the Nginx software cannot be found, the uninstallation is complete.
- 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
Parent topic: Nginx Porting Guide