在Ubuntu上更新Nginx常用方法如下:
sudo cp -r /etc/nginx /etc/nginx_backup
。sudo apt update
。sudo apt install nginx
。若要指定版本,可运行sudo apt install nginx=<version>
(需提前通过apt-cache madison nginx
查看可用版本)。sudo systemctl restart nginx
。nginx -v
。curl -fsSL https://nginx.org/keys/nginx_signing.key | sudo gpg --dearmor -o /etc/apt/keyrings/nginx.gpg
。echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/nginx.gpg] https://nginx.org/packages/ubuntu $(lsb_release -cs) nginx" | sudo tee /etc/apt/sources.list.d/nginx.list
。sudo apt update && sudo apt install nginx
。sudo systemctl restart nginx
。