想透過 apt-get 把 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