Ubuntu 14.04上卸載nginx之后重新安裝沒有重新生成配置文件的解決方法
在配置nginx做實驗時配置錯了,導致訪問不了虛擬主機。一狠心把nginx的配置文件目錄(/etc/nginx)都刪除了,而且我沒有備份這些配置文件,因此想重裝nginx。
本來以為直接使用如下apt-get指令
|
1
2
|
$ sudo apt-get --purge remove nginx
$ sudo apt-get install nginx
|
就可以搞定,但實際上並沒有有自動產生nginx的配置文件,連/etc/nginx目錄都沒產生。
於是autoremove
|
1
2
3
|
$ sudo apt-get --purge remove nginx
$ sudo apt-get autoremove
$ sudo apt-get install nginx
|
提示
|
1
|
awk: cannot open /etc/nginx/nginx.conf (No such file or directory)
|
雖然產生了/etc/nginx目錄了,但只有部分配置文件
|
1
|
conf.d sites-available sites-enabled
|
於是
|
1
2
3
|
$ sudo apt-get --purge remove nginx
$ sudo apt-get autoremove
$ dpkg --get-selections | grep nginx
|
羅列出與nginx相關的軟件
|
1
|
nginx-common
|
然后卸載並重新安裝
|
1
2
|
$ sudo apt-get --purge remove nginx-common
$ sudo apt-get install nginx
|
