作業系統 : Ubuntu
前言#
起初以為安裝、解除安裝任何套件就是
$ sudo apt-get install module
$ sudo apt-get remove module
直到遇到Nginx時,才發現這招已經行不通了
1. 安裝#
首先,先安裝一次Nginx,使用Ubuntu下的模組管理工具
$ sudo apt-get install nginx
2. 解除安裝#
同樣使用apt來移除Nginx
$ sudo apt-get remove nginx
這邊使用autoremove來移除不需要的依賴套件
$ sudo apt-get autoremove
刪除nginx資料夾
$ sudo rm -rf /etc/nginx
3. 重新安裝Nginx#
$ sudo apt-get update
$sudo apt-get install nginx
接著就會看到console報錯了
dpkg: error processing package nginx (--configure):
dependency problems - leaving unconfigured
Processing triggers for libc-bin (2.23-0ubuntu9) ...
Errors were encountered while processing:
nginx-core
nginx
上網爬了文後,找到解法如下
$ sudo apt-get --purge remove nginx
這樣可以移除不再需要的依賴套件
再使用一次autoremove
$ sudo apt-get autoremove
接著查看還有沒有與Nginx相關的套件
$ dpkg --get-selections | grep nginx
如果還有看到nginx相關的套件,不要懷疑
$ sudo apt-get --purge remove 套件名稱
重新安裝 Nginx#
$ sudo apt-get install nginx
檢查版本
nginx -v
並執行nginx的設定語法檢查
sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
