技术解析

请教从 Nginx 1.6.2 升级到最新 1.11.5 得正确姿势
0
2021-05-21 02:56:18
idczone

是这样的,我小白一个,翻了好多教程折腾把 www.uptownboy.cn 弄好了。

觉得还可以继续折腾,又试着想用 Let's Encrypt 给加上 HTTPS , VPS 上 Debian 8 装的是 1.6.2 ,发现原来 Nginx 从 1.9.2 才开始支持 HTTP 2.0 ,开始查直接 apt-get update 的方法,结果报错:

The following packages will be upgraded:
  nginx
1 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/711 kB of archives.
After this operation, 2,396 kB of additional disk space will be used.
Reading changelogs... Done
(Reading database ... 46836 files and directories currently installed.)
Preparing to unpack .../nginx_1.10.2-1~jessie_amd64.deb ...
Unpacking nginx (1.10.2-1~jessie) over (1.6.2-5+deb8u2) ...
dpkg: error processing archive /var/cache/apt/archives/nginx_1.10.2-1~jessie_amd64.deb (--unpack):
 trying to overwrite '/etc/default/nginx', which is also in package nginx-common 1.6.2-5+deb8u2
dpkg-deb: error: subprocess paste was killed by signal (Broken pipe)
E: Sub-process /usr/bin/dpkg returned an error code (1)

还有另外一种方法但是不敢往下编译, wget http://nginx.org/download/nginx-1.11.5.tar.gz 把最新版本拉下来了, Nginx -V 查看原来 1.6.2 的参数如下:

--with-cc-opt美国服务器='-g -O2 -fstack-protector-strong -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2' --with-ld-opt=-Wl,-z,relro --prefix=/usr/share/nginx --conf-path=/etc/nginx/nginx.conf --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --lock-path=/var/lock/nginx.lock --pid-path=/run/nginx.pid --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --with-debug --with-pcre-jit --with-ipv6 --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-http_auth_request_module --with-http_addition_module --with-http_dav_module --with-http_geoip_module --with-http_gzip_static_module --with-http_image_filter_module --with-http_spdy_module --with-http_sub_module --with-http_xslt_module --with-mail --with-mail_ssl_module --add-module=/build/nginx-ryOGNl/nginx-1.6.2/debian/modules/nginx-auth-pam --add-module=/build/nginx-ryOGNl/nginx-1.6.2/debian/modules/nginx-dav-ext-module --add-module=/build/nginx-ryOGNl/nginx-1.6.2/debian/modules/nginx-echo --add-module=/build/nginx-ryOGNl/nginx-1.6.2/debian/modules/nginx-upstream-fair --add-module=/build/nginx-ryOGNl/nginx-1.6.2/debian/modules/ngx_http_substitutions_filter_module

最后几行都有--add-module=/build/nginx-ryOGNl/nginx-1.6.2/debian/,我担心这个路径我直接在 1.11.5 里面./configure 会编译出错。

想请教一下大神们, Nginx 正确升级的姿势应该是如何?谢谢


重新编译,备份原来的 nginx 可执行文件,替换后运行没问题就行,有问题就换回来....

apt-get -t jessie-backports install nginx
or
apt-get -t jessie-backports upgrade nginx
试试把, debian 8 的 bpo 是 1.9.10
但讲道理, Nginx 还是编译的好, https://imququ.com/post/my-nginx-conf.html

按文档说的操作,很轻松
http://nginx.org/en/linux_packages.html#mainline

backport +1

谢谢! apt-get -t jessie-backports install nginx 可以了
但现在 Nginx -V 配置里面还没有 --with-http_v2_module ,需要 ./configure 然后 make 吗?

./configure
--with-pcre=../pcrelib
--with-pcre-jit
--with-zlib=../zlibdir
--with-http_ssl_module
--with-stream
--with-stream_ssl_module
--with-http_v2_module
--with-ipv6
省略了部分 path 设置

既然没有的话,那就只能编译,卸载二进制包的 nginx 吧

难道你们不知道 debain 除了 nginx 还有 nginx-full 吗?
https://packages.debian.org/jessie-backports/nginx-full

这种软件包冲突,最快的办法是卸掉软件包然后重新装上新的。反正又不会丢配置,怕什么。
想玩高版本的话可以直接下载 experimental 版, 1.11.5 ,反正也没什么不稳定的。

数据地带为您的网站提供全球顶级IDC资源
在线咨询
专属客服