Ubuntu完全卸载nginx服务器

方法1

使用‘sudo apt-get –purge remove nginx’彻底删除

# sudo service nginx stop
# sudo apt-get --purge remove nginx
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
  fontconfig-config fonts-dejavu-core libfontconfig1 libgd3 libjbig0 libjpeg-turbo8 libjpeg8
  libnginx-mod-http-image-filter libnginx-mod-http-xslt-filter libnginx-mod-mail
  libnginx-mod-stream libtiff5 libwebp6 libxpm4 libxslt1.1 nginx-common nginx-core
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED:
  nginx*
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
After this operation, 45.1 kB disk space will be freed.
Do you want to continue? [Y/n] y
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
        LANGUAGE = (unset),
        LC_ALL = (unset),
        LC_CTYPE = "UTF-8",
        LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to a fallback locale ("en_US.UTF-8").
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
(Reading database ... 117708 files and directories currently installed.)
Removing nginx (1.18.0-0ubuntu1) ...

方法2

自动移除全部不使用的软件包

sudo apt-get autoremove

列出与nginx相关的软件,并依次删除显示的软件,这个方法更加通用,我照猫画虎使用在php上面,也非常靠谱(php8.0-fpm)

dpkg --get-selections|grep nginx
sudo apt-get --purge remove nginx
sudo apt-get --purge remove nginx-common
sudo apt-get --purge remove nginx-cor

使用ps命令查看相关进程,-A显示有限信息,-l显示详细信息 -e显示所有进程,aux显示系统所有进程

ps -le | grep nginx

参考材料如下
https://blog.csdn.net/adley_app/article/details/79223221

ps命令
http://c.biancheng.net/view/1062.html

删除apache2
https://blog.csdn.net/dazhi_100/article/details/43121179