Ubuntu20.04でnginxをアンインストール(削除)する方法
まずはインストールしているnginxのバージョンを確認
root@ホスト名:~# nginx -v
nginx version: nginx/1.18.0 (Ubuntu)
完全に削除する。
sudo apt purge nginx nginx-common nginx-full
すると下記の画面となる。
root@ホスト名:~# sudo apt purge nginx nginx-common nginx-full
Reading package lists… Done
Building dependency tree
Reading state information… Done
Package 'nginx-full' is not installed, so not removed
The following packages were automatically installed and are no longer required:
fontconfig-config fonts-dejavu-core libfontconfig1 libgd3 libjbig0
libjpeg-turbo8 libjpeg8 libtiff5 libwebp6 libxpm4 linux-headers-5.4.0-66
linux-headers-5.4.0-66-generic linux-image-5.4.0-66-generic
linux-modules-5.4.0-66-generic linux-modules-extra-5.4.0-66-generic
python3-pyparsing
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED:
libnginx-mod-http-image-filter* libnginx-mod-http-xslt-filter*
libnginx-mod-mail* libnginx-mod-stream* nginx* nginx-common* nginx-core*
python3-certbot-nginx*
0 upgraded, 0 newly installed, 8 to remove and 81 not upgraded.
After this operation, 2,420 kB disk space will be freed.
Do you want to continue? [Y/n] y ←YesのYを押す。
(Reading database … 146407 files and directories currently installed.)
Removing python3-certbot-nginx (0.40.0-0ubuntu0.1) …
Removing nginx (1.18.0-0ubuntu1.3) …
Removing nginx-core (1.18.0-0ubuntu1.3) …
Removing libnginx-mod-http-image-filter (1.18.0-0ubuntu1.3) …
Removing libnginx-mod-http-xslt-filter (1.18.0-0ubuntu1.3) …
Removing libnginx-mod-mail (1.18.0-0ubuntu1.3) …
Removing libnginx-mod-stream (1.18.0-0ubuntu1.3) …
Removing nginx-common (1.18.0-0ubuntu1.3) …
Processing triggers for man-db (2.9.1-1) …
(Reading database … 146319 files and directories currently installed.)
Purging configuration files for libnginx-mod-mail (1.18.0-0ubuntu1.3) …
Purging configuration files for libnginx-mod-http-image-filter (1.18.0-0ubuntu1.3) …
Purging configuration files for libnginx-mod-stream (1.18.0-0ubuntu1.3) …
Purging configuration files for nginx-common (1.18.0-0ubuntu1.3) …
dpkg: warning: while removing nginx-common, directory '/var/www/html' not empty so not removed
Purging configuration files for libnginx-mod-http-xslt-filter (1.18.0-0ubuntu1.3) …
Processing triggers for systemd (245.4-4ubuntu3.15) …
Processing triggers for ufw (0.36-6) …
root@ホスト名:~#
再度バージョンを確認すると下記のように表示されます。
root@ホスト名:~# nginx -v
-bash: /usr/sbin/nginx: No such file or directory
削除されました。