国产xxxx99真实实拍_久久不雅视频_高清韩国a级特黄毛片_嗯老师别我我受不了了小说

資訊專欄INFORMATION COLUMN

記一次重裝nginx時(shí)遇到的問(wèn)題

Vultr / 2327人閱讀

摘要:起因之前在網(wǎng)上看文章提到說(shuō),通過(guò)的方式安裝,可能安裝不是最新版本的情況,考慮到在下第一次安裝,以后肯定會(huì)有卸載重新安裝新版本的需求,剛好剛開始學(xué)習(xí),索性練習(xí)下卸載重裝的過(guò)程。

起因

之前在網(wǎng)上看文章提到說(shuō),通過(guò)apt-get的方式安裝nginx,可能安裝不是最新版本的情況,考慮到在Ubuntu下第一次安裝nginx,以后肯定會(huì)有卸載重新安裝新版本的需求,剛好剛開始學(xué)習(xí)nginx,索性練習(xí)下卸載重裝的過(guò)程。


安裝

使用Ubuntu下的包管理工具apt來(lái)安裝nginx

$ sudo apt-get install nginx
卸載

同樣使用apt來(lái)卸載nginx

$ sudo apt-get remove nginx

sudo apt-get autoremove命令幫我們卸載不再需要的依賴包
在這里我們卸載nginx相關(guān)的依賴包

$ sudo apt-get autoremove

刪除nginx配置文件夾

$ sudo rm -rf /etc/nginx
重新安裝nginx
# 更新源
$ sudo apt update
$ sudo apt-get install nginx

然而控制臺(tái)報(bào)錯(cuò):

Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details.
invoke-rc.d: initscript nginx, action "start" failed.
dpkg: error processing package nginx-core (--configure):
 subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of nginx:
 nginx depends on nginx-core (>= 1.10.3-0ubuntu0.16.04.2) | nginx-full (>= 1.10.3-0ubuntu0.16.04.2) | nginx-light (>= 1.10.3-0ubuntu0.16.04.2) | nginx-extras (>= 1.10.3-0ubuntu0.16.04.2); however:
  Package nginx-core is not configured yet.
  Package nginx-full is not installed.
  Package nginx-light is not installed.
  Package nginx-extras is not installed.
 nginx depends on nginx-core (<< 1.10.3-0ubuntu0.16.04.2.1~) | nginx-full (<< 1.10.3-0ubuntu0.16.04.2.1~) | nginx-light (<< 1.10.3-0ubuntu0.16.04.2.1~) | nginx-extras (<< 1.10.3-0ubuntu0.16.04.2.1~); however:
  Package nginx-core is not configured yet.
 No apport report written because the error message indicates its a followup error from a previous failure.
 Package nginx-full is not installed.
  Package nginx-light is not installed.
  Package nginx-extras is not installed.

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
E: Sub-process /usr/bin/dpkg returned an error code (1)

查看nginx.service狀態(tài)

$ systemctl status nginx.service
● nginx.service - A high performance web server and a reverse proxy server
   Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Sat 2018-03-17 23:16:40 CST; 1min 18s ago
  Process: 26795 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=1/FAILURE)
 Main PID: 18259 (code=exited, status=0/SUCCESS)

Mar 17 23:16:40 VM-0-5-ubuntu systemd[1]: Starting A high performance web server and a reverse proxy server...
Mar 17 23:16:40 VM-0-5-ubuntu nginx[26795]: nginx: [emerg] open() "/etc/nginx/nginx.conf" failed (2: No such file or direMar 17 23:16:40 VM-0-5-ubuntu nginx[26795]: nginx: configuration file /etc/nginx/nginx.conf test failed
Mar 17 23:16:40 VM-0-5-ubuntu systemd[1]: nginx.service: Control process exited, code=exited status=1
Mar 17 23:16:40 VM-0-5-ubuntu systemd[1]: Failed to start A high performance web server and a reverse proxy server.
Mar 17 23:16:40 VM-0-5-ubuntu systemd[1]: nginx.service: Unit entered failed state.
Mar 17 23:16:40 VM-0-5-ubuntu systemd[1]: nginx.service: Failed with result "exit-code".

仔細(xì)看報(bào)錯(cuò)信息,獲取到兩個(gè)信息點(diǎn):

Package nginx-core is not configured yet.

Package nginx-full/nginx-light/nginx-extras is not installed.

于是上網(wǎng)搜,網(wǎng)上找說(shuō)可能是apache占用了80端口導(dǎo)致報(bào)錯(cuò)

查看端口占用情況

$ sudo netstat -nlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1287/sshd
udp        0      0 0.0.0.0:68              0.0.0.0:*                           891/dhclient
udp        0      0 172.21.0.5:123          0.0.0.0:*                           1231/ntpd
udp        0      0 127.0.0.1:123           0.0.0.0:*                           1231/ntpd
udp        0      0 0.0.0.0:123             0.0.0.0:*                           1231/ntpd
udp6       0      0 :::123                  :::*                                1231/ntpd

發(fā)現(xiàn)80端口沒(méi)被占用,而且systemctl status nginx.service的提示信息也沒(méi)提及80端口被占用,如果提示信息中說(shuō)80端口被占用,可以執(zhí)行以下兩步試試:

終止apache運(yùn)行

$ sudo service apache2 stop

重新安裝nginx

$ sudo apt-get install nginx
了解詳細(xì)信息請(qǐng)看askubuntu上的提問(wèn)

上述情況與我的并不相符,于是換個(gè)思路,報(bào)錯(cuò)信息中提及nginx的配置文件不存在,思考為什么卸載重裝nginx,卻沒(méi)有生成配置文件?
和第一次安裝的時(shí)候不一樣,然后百度上搜nginx卸載重裝后配置文件沒(méi)有重新生成,找到了類似的問(wèn)題,給出了如下的操縱步驟:

卸載nginx不保留配置文件

$ sudo apt-get --purge remove nginx

Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
  fontconfig-config fonts-dejavu-core libfontconfig1 libgd3 libjbig0 libjpeg-turbo8 libjpeg8 libtiff5 libvpx3 libxpm4
  libxslt1.1 nginx-common nginx-core
Use "sudo apt autoremove" to remove them.
The following packages will be REMOVED:
  nginx*
0 upgraded, 0 newly installed, 1 to remove and 205 not upgraded.
2 not fully installed or removed.
After this operation, 37.9 kB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 66386 files and directories currently installed.)
Removing nginx (1.10.3-0ubuntu0.16.04.2) ...
Setting up nginx-core (1.10.3-0ubuntu0.16.04.2) ...
Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details.
invoke-rc.d: initscript nginx, action "start" failed.
dpkg: error processing package nginx-core (--configure):
 subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
 nginx-core
E: Sub-process /usr/bin/dpkg returned an error code (1)

卸載自動(dòng)安裝且不再需要的依賴包

$ sudo apt-get autoremove

Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED:
  fontconfig-config fonts-dejavu-core libfontconfig1 libgd3 libjbig0 libjpeg-turbo8 libjpeg8 libtiff5 libvpx3 libxpm4
  libxslt1.1 nginx-common nginx-core
0 upgraded, 0 newly installed, 13 to remove and 205 not upgraded.
1 not fully installed or removed.
After this operation, 9,745 kB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 66383 files and directories currently installed.)
Removing nginx-core (1.10.3-0ubuntu0.16.04.2) ...
Removing libgd3:amd64 (2.1.1-4ubuntu0.16.04.8) ...
Removing libfontconfig1:amd64 (2.11.94-0ubuntu1.1) ...
Removing fontconfig-config (2.11.94-0ubuntu1.1) ...
Removing fonts-dejavu-core (2.35-1) ...
Removing libtiff5:amd64 (4.0.6-1ubuntu0.2) ...
Removing libjbig0:amd64 (2.1-3.1) ...
Removing libjpeg8:amd64 (8c-2ubuntu8) ...
Removing libjpeg-turbo8:amd64 (1.4.2-0ubuntu3) ...
Removing libvpx3:amd64 (1.5.0-2ubuntu1) ...
Removing libxpm4:amd64 (1:3.5.11-1ubuntu0.16.04.1) ...
Removing libxslt1.1:amd64 (1.1.28-2.1ubuntu0.1) ...
Removing nginx-common (1.10.3-0ubuntu0.16.04.2) ...
Processing triggers for libc-bin (2.23-0ubuntu9) ...
Processing triggers for man-db (2.7.5-1) ...

篩選已安裝軟件包中與nginx有關(guān)的

$ dpkg --get-selections | grep nginx

nginx-common                                    deinstall

卸載nginx-common不保留配置文件

$ sudo apt-get --purge remove nginx-common

Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED:
  nginx-common*
0 upgraded, 0 newly installed, 1 to remove and 205 not upgraded.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] y
(Reading database ... 66243 files and directories currently installed.)
Removing nginx-common (1.10.3-0ubuntu0.16.04.2) ...
Purging configuration files for nginx-common (1.10.3-0ubuntu0.16.04.2) ...
dpkg: warning: while removing nginx-common, directory "/var/www/html" not empty so not removed

重新安裝nginx

$ sudo apt-get install nginx
...

查看版本號(hào),執(zhí)行nginx配置文件語(yǔ)法檢測(cè)

$ nginx -v
nginx version: nginx/1.10.3 (Ubuntu)

$ sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

雖然nginx已經(jīng)重裝好了,但是一路下來(lái)還有幾個(gè)困惑:

apt-get autoremove到底是按什么規(guī)則卸載軟件?

為什么nginx-common沒(méi)有在一開始的時(shí)候卸載?

1. apt-get autoremove到底是按什么規(guī)則卸載軟件?

apt-get autoremove:刪除,自動(dòng)安裝的,且不再需要的
(不被其他軟件當(dāng)作依賴的)軟件包

舉個(gè)栗子: 通過(guò)apt-get方式安裝nginx時(shí),會(huì)通過(guò)引導(dǎo)自動(dòng)安裝所需的依賴包(nginx-core),而當(dāng)我們卸載nginx后,
那些自動(dòng)安裝的依賴包就成為不再需要的軟件包(nginx-core),通過(guò)apt-get autoremove會(huì)自動(dòng)清理它們

既然會(huì)自動(dòng)刪除不再需要的軟件包,那么為什么nginx-common沒(méi)被刪除?

2. 為什么nginx-common沒(méi)有在apt-get autoremove的時(shí)候卸載?

不知道細(xì)心的童鞋發(fā)現(xiàn)沒(méi),我們?cè)谛遁dnginx的時(shí)候,
手動(dòng)刪除了nginx的配置文件夾(sudo rm -rf /etc/nginx)。
那這些配置文件夾和nginx-common軟件包有什么關(guān)系呢?

通過(guò)查找ubuntu packages,找到了Ubuntu16.0.4下nginx-common軟件包的文件清單。

按照清單上的目錄手動(dòng)排查,發(fā)現(xiàn)本機(jī)上除了手動(dòng)刪除的/etc/nginx目錄不存在,文件清單內(nèi)的其他文件都沒(méi)有被刪除,
猜測(cè)可能是nginx-common軟件包完整性被破壞,導(dǎo)致autoremove的時(shí)候沒(méi)有被刪除,當(dāng)然這只我的猜測(cè)。

問(wèn)題回答后續(xù)補(bǔ)充:

整理完全卸載nginx命令時(shí),發(fā)現(xiàn)執(zhí)行如下命令,ngnix的配置文件并沒(méi)有被刪除

$ sudo apt-get remove --purge nginx

查閱ubuntu packages發(fā)現(xiàn),nginx依賴nginx-core,nginx-core依賴nginx-common,且其中nginx的配置文件屬于nginx-common軟件包配置文件的一部分。

執(zhí)行如下命令進(jìn)一步驗(yàn)證

# 卸載nginx-common ,nginx配置文件不會(huì)被刪除
$ sudo apt-get remove nginx-common
...
# 卸載nginx-common,nginx配置文件已經(jīng)被刪除(包括但不限于)
$ sudo apt-get remove --purge nginx-common
$ find /etc/nginx/
find: ‘/etc/nginx/’: No such file or directory
推翻之前的猜測(cè):

apt-get autoremove執(zhí)行時(shí),nginx-common軟件包已經(jīng)被選擇用于卸載( deinstall ),但是實(shí)際還沒(méi)有卸載。

$ dpkg --get-selections| grep nginx
nginx-common                                    deinstall

了解更多關(guān)于deinstall,點(diǎn)擊這里,如果有知道為什么的同學(xué)請(qǐng)不吝賜教。


命令匯總
# 完全卸載nginx
$ sudo apt-get remove --purge nginx
$ sudo apt-get autoremove --purge

# 更新nginx,保留配置文件
# 親測(cè)nginx.conf不會(huì)被刪除和覆蓋,但保險(xiǎn)起見還是建議先備份
$ sudo apt-get remove nginx
$ sudo apt-get autoremove
$ sudo apt update
$ sudo apt-get install nginx

# 安裝軟件包
# sudo apt-get install 軟件包名稱`
# eg: 
$ sudo apt-get install nginx

# 卸載軟件包
# sudo apt-get remove 軟件包名稱
# eg: 
$ sudo apt-get remove nginx

# 卸載軟件包且不保留配置文件
# sudo apt-get remove --purge 軟件包名稱
# eg:
$ sudo apt-get remove --purge nginx

# 卸載自動(dòng)安裝的軟件包且不保留配置文件
# sudo apt-get autoremove --purge

# 列出本地軟件包列表
# dpkg --get-selections [| grep 篩選關(guān)鍵字]
# eg:(列出本地所有軟件包)
$ dpkg --get-selections
# eg:(列出本地與ngnix有關(guān)的軟件包)
$ dpkg --get-selections | grep nginx

# 查看進(jìn)程信息
# ps -ef [| grep 篩選關(guān)鍵字]
# eg:(列出所有進(jìn)程信息)
$ ps -ef
# eg:(列出與nginx有關(guān)的進(jìn)程信息)
$ ps -ef | grep nginx

# 查看端口占用信息
$ sudo netstat -nlp

參考鏈接匯總
Package nginx-core not configured yet.Sub-process :/user/bin/dpkg returned an error code(1)

nginx fail to install on Ubuntu 15.10 server

Ubuntu 14.04上卸載nginx之后重新安裝沒(méi)有重新生成配置文件的解決方法

在 xenial 發(fā)行版中 all 硬件架構(gòu)下的 nginx-common 軟件包文件清單

What is difference between the options “autoclean”, “autoremove” and “clean”?

dpkg --get-selections shows packages marked “deinstall”

文章版權(quán)歸作者所有,未經(jīng)允許請(qǐng)勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。

轉(zhuǎn)載請(qǐng)注明本文地址:http://specialneedsforspecialkids.com/yun/39849.html

相關(guān)文章

  • 【踩坑記錄】一次MySQL主從復(fù)制延遲

    摘要:最近開發(fā)中遇到的一個(gè)主從延遲的坑,記錄并總結(jié),避免再次犯同樣的錯(cuò)誤。運(yùn)行時(shí)查詢?yōu)榭眨瑘?zhí)行完畢后查詢時(shí)內(nèi)容存在,初步懷疑是主從延遲問(wèn)題。報(bào)錯(cuò)只是部分失敗,確定是主從延遲的問(wèn)題。接下來(lái),會(huì)去學(xué)習(xí)主從復(fù)制的原理,敬請(qǐng)期待。 最近開發(fā)中遇到的一個(gè)MySQL主從延遲的坑,記錄并總結(jié),避免再次犯同樣的錯(cuò)誤。 情景 一個(gè)活動(dòng)信息需要審批,審批之后才能生效。因?yàn)橹蠡顒?dòng)要編輯,編輯后也可能觸發(fā)審批,審...

    cartoon 評(píng)論0 收藏0

發(fā)表評(píng)論

0條評(píng)論

最新活動(dòng)
閱讀需要支付1元查看
<