以下是在Ubuntu上更新升级Nginx的步骤:
sudo cp -r /etc/nginx /etc/nginx_backup
。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 apt install nginx=<version>
)。sudo systemctl restart nginx
。nginx -v
查看版本,systemctl status nginx
查看服务状态。sudo apt install build-essential libpcre3 libpcre3-dev libssl-dev zlib1g-dev
等。cd /usr/local/src
,wget http://nginx.org/download/nginx-<version>.tar.gz
,tar -zxvf nginx-<version>.tar.gz
。cd nginx-<version>
。./configure --prefix=/usr/local/nginx --conf-path=/etc/nginx/nginx.conf
等(根据需求配置)。sudo make
,sudo make install
。/etc/systemd/system/nginx.service
并配置。sudo systemctl start nginx
。