Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux基礎 >> 關於Linux

Ubuntu/Debian VPS 用 apt-get 升級 nginx 的實作要點

想透過 apt-get 把 nginx 升到官方源的版本,只要加上官方套件庫即可。

一、加入 nginx 官方源

編輯 /etc/apt/sources.list,依發行版加入對應兩行:

# Ubuntu
deb https://nginx.org/packages/ubuntu/ lucid nginx
deb-src https://nginx.org/packages/ubuntu/ lucid nginx

# Debian
deb https://nginx.org/packages/debian/ squeeze nginx
deb-src https://nginx.org/packages/debian/ squeeze nginx

實際使用時,請把 lucid/squeeze 換成你系統對應的發行代號。

二、更新並安裝

apt-get update
apt-get install nginx

三、遇到設定檔衝突怎麼辦

安裝過程中若出现以下提示:

Configuration file `/etc/nginx/nginx.conf'
==> Modified (by you or by a script) since installation.
==> Package distributor has shipped an updated version.
What would you like to do about it ? Your options are:
Y or I : install the package maintainer's version
N or O : keep your currently-installed version
D : show the differences between the versions
Z : background this process to examine the situation
The default action is to keep your current version.
*** nginx.conf (Y/I/N/O/D/Z) [default=N] ?

輸入 N 保留既有的 nginx.conf,避免把現有站點設定洗掉;升級完成後再自行比對新版的差異,把需要的項目補進去。

四、重啟並驗證

service nginx restart
nginx -v
Copyright © Linux教程網 All Rights Reserved