ubuntu系统安装最新的nginx版本
1.导入官方 nginx 签名密钥
curl https://nginx.org/keys/nginx_signing.key | gpg --dearmor \
| sudo tee /usr/share/keyrings/nginx-archive-keyring.gpg >/dev/null
2.设置稳定版本的nginx安装源
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
3.安装最新主线版本
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
4.执行安装
第2和第3选一个来安装即可
sudo apt update
sudo apt install nginx
nginx -v
可以到nginx官网查看最新的版本号是否和打印出来的相同
如果先安装了稳定版本的nginx,也可以执行第3步后,再升级,升级后重载下配置就好了
sudo apt upgrade nginx
License:
CC BY 4.0