IMG_0384

Ubuntu 安裝最新 nginx

原文網址:http://nginx.org/en/linux_packages.html#Ubuntu

先用apt安裝需要用到的東西

sudo apt install curl gnupg2 ca-certificates lsb-release ubuntu-keyring

從nginx下載gpg key

curl https://nginx.org/keys/nginx_signing.key | gpg --dearmor \
    | sudo tee /usr/share/keyrings/nginx-archive-keyring.gpg >/dev/null

驗證gpg key是否為nginx簽名

gpg --dry-run --quiet --import --import-options import-show /usr/share/keyrings/nginx-archive-keyring.gpg

設定apt儲存庫為穩定版

echo "deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg] \
http://nginx.org/packages/ubuntu `lsb_release -cs` nginx" \
    | sudo tee /etc/apt/sources.list.d/nginx.list

設定apt儲存庫為最新版

echo "deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg] \
http://nginx.org/packages/mainline/ubuntu `lsb_release -cs` nginx" \
    | sudo tee /etc/apt/sources.list.d/nginx.list

設定儲存庫來源為nginx

echo -e "Package: *\nPin: origin nginx.org\nPin: release o=nginx\nPin-Priority: 900\n" \
    | sudo tee /etc/apt/preferences.d/99nginx

更新套件清單

sudo apt update
sudo apt install nginx

檢查來源庫nginx版本

apt-cache madison nginx

安裝nginx

sudo apt install nginx

將nginx註冊為服務並啟動

systemctl enable nginx
systemctl start nginx

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *