在Debian系统中更新Nginx,你可以遵循以下步骤:
sudo apt update
sudo apt upgrade
sudo apt install nginx
sudo apt update
sudo apt upgrade nginx
sudo apt remove nginx
然后从源代码编译Nginx。这需要你先安装编译所需的依赖包:
sudo apt install build-essential libpcre3 libpcre3-dev zlib1g-dev openssl libssl-dev
接下来,下载Nginx的最新源代码:
wget http://nginx.org/download/nginx-<version>.tar.gz
tar -zxvf nginx-<version>.tar.gz
cd nginx-<version>
配置编译选项(根据你的需求进行修改):
./configure --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-http_auth_request_module --with-threads --with-stream --with-http_slice_module --with-mail --with-mail_ssl_module --with-file-aio --with-http_v3_module
编译并安装Nginx:
make
sudo make install
sudo systemctl restart nginx
sudo systemctl status nginx
现在,你的Nginx应该已经更新到最新版本。请注意,从源代码编译Nginx可能会覆盖之前通过包管理器安装的配置文件和模块。因此,在执行此操作之前,请确保备份所有重要数据。