- 背景(发现问题)
在使用 ansible apt 模块卸载时,发现Nginx配置文件目录还在,在本机使用apt install重新安装会报错。 - 问题分析:
- 因为测试安装的ubuntu主机之前安装过nginx1.18, 且修改过和添加过配置文件。
所以正常使用 apt remove 卸载 保留了配置文件。 - 当使用ansible apt模块卸载时,保留了配置文件,再使用ansible apt 重新安装时导致服务无法以旧的配置文件启动。
- 因为测试安装的ubuntu主机之前安装过nginx1.18, 且修改过和添加过配置文件。
- 处理过程:
- 首先想到的是手动删除配置文件,重新安装(rm -rf /etc/nginx /var/log/nginx)
- 使用nginx install nginx 重新安装后没有报错,但是无配置文件
- 尝试方法一(未解决):
- Debian上完整卸载nginx 并重新安装
- 卸载 sudu apt-get remove nginx #可删除除 /etc/nginx配置文件外的所有文件 sudo apt-get purge nginx or rm -rf /etc/nginx #删除nginx 配置文件 sudo apt-get autoremove #自动删除安装 nginx时安装的依赖包 - 重装 apt-get -o dpkg::options::=--force-confmiss --reinstall install nginx
- 解决方法:
- 因未完全卸载nginx及其他 nginx 的安装包导致
- 1)完全卸载:
#卸载 nginx开头的所有软件包 apt purge nginx* apt autoremove nginx* #确保已经没有残留文件 whereis nginx find / -iname nginx
-
- 重新安装:
apt install nginx ll /etc/nginx
06-24
1935
01-30
4273
09-26
7841
09-13
1113