在一些云服务器有的会默认安装有nginx
,默认安装nginx
不是最新版本,或者默认执行sudo apt-get install nginx
无法安装最新,那么这篇文章可能会帮到你。
系统:ubuntu 16.0.4
安装
首先更新源到系统支持的最新stable
(稳定)版本
sudo apt-add-repository ppa:nginx/stable
sudo apt-get update
然后执行安装命令
sudo apt-get install nginx
这个过程基本会很顺利的完成,如果遇到问题请留言。
基本上这里已经完成了nginx
最新版的安装,执行
nginx -v
可以查看是否安装成功,和安装的版本
#执行 nginx -v 的输出
nginx version: nginx/1.16.1
卸载
2.1 删除nginx,–purge包括配置文件
sudo apt-get --purge remove nginx
2.2 自动移除全部不使用的软件包
sudo apt-get autoremove
2.3 罗列出与nginx相关的软件
dpkg --get-selections|grep nginx
执行1.3的结果:
stephen@stephen-OptiPlex-390:~$ dpkg --get-selections|grep nginx
nginx install
nginx-common install
nginx-core install
2.4 删除1.3查询出与nginx有关的软件
sudo apt-get --purge remove nginx
sudo apt-get --purge remove nginx-common
sudo apt-get --purge remove nginx-core
这样就可以完全卸载掉nginx包括配置文件
2.5 查看nginx正在运行的进程,如果有就kill掉
ps -ef |grep nginx
看下nginx还有没有启动,一般执行完1后,nginx还是启动着的,如下:
stephen@stephen-OptiPlex-390:~$ ps -ef |grep nginx
root 7875 2317 0 15:02 ? 00:00:00 nginx: master process /usr/sbin/nginx
www-data 7876 7875 0 15:02 ? 00:00:00 nginx: worker process
www-data 7877 7875 0 15:02 ? 00:00:00 nginx: worker process
www-data 7878 7875 0 15:02 ? 00:00:00 nginx: worker process
www-data 7879 7875 0 15:02 ? 00:00:00 nginx: worker process
stephen 8321 3510 0 15:20 pts/0 00:00:00 grep --color=auto nginx
2.6.kill nginx进程
sudo kill -9 7875 7876 7877 7879
2.7.全局查找与nginx相关的文件
sudo find / -name nginx*
2.8 依依删除4列出的所有文件
sudo rm -rf file
网友评论