APPNODE 手动升级Nginx到1.22.0步骤,亲测。

jxgame 2022-8-1 2403

写在前面,本人对服务器的维护也是一个菜菜,说的不对的地方,请大家包涵。

升级前准备:查看原安装的Nginx扩展,之前可能默认安装有brotli,lua。希望你没有启用它,旧的扩展都不能再使用到新版本上的(见备注1)。

  1. 下载nginx 1.22.0稳定版 http://nginx.org/en/download.html
  2. 将它上传到服务器。并解压 tar -zxvf nginx-1.22.0.tar.gz
  3. 进入解压好的目录,运行 nginx -V 能看到之前的Nginx版本,注意:一定要将配置参数复制保存好。 configure arguments:之后的字符。
  4. 运行:./configure (将上一步复制的参数放这后面)
  5. 运行:make
  6. 运行:mv /usr/sbin/nginx /usr/sbin/nginx.old 这一步是将原来的Nginx做一个备份
  7. 运行:cp ./objs/nginx /usr/sbin/ 将新的nginx复制过去。
  8. 运行:make upgrade (将第3步复制的参数放这后面)

    出现这句话,一般来说升级完成了。
    This program built for x86_64-redhat-linux-gnu

    验证升级是否成功,可以看在APPNODE中,网站管理-->组件管理-->Nginx 标题后的更新图标点一下,然后,再试一下重启Nginx


    以上是本菜菜的升级过程,亲测成功的。欢迎交流。


    备注1:
    扩展可能造成Nginx升级完成后启动失败。
    可以查看 /var/log/nginx/error.log 找到具体原因。
    如果提示 brotli 版本问题,可以下载https://note.youdao.com/s/L5bSjll1的.so文件复制到 /etc/nginx/modules/ 目录下。再重新启动Nginx
    如果Nginx能正常启动,但是站点无法打开,可以在:网站管理-运行环境管理-变更 重新配置一下就可以了。

最新回复 (9)
  • jxgame 2022-8-1
    引用 2

    出现提示:
    the HTTP rewrite module requires the PCRE library.

    解决办法:

    yum -y install pcre-devel openssl openssl-devel

    然后继续运行之前命令

  • ysmaster 2022-8-11
    引用 3
    感谢分享。
  • maher 2022-12-15
    引用 4
    已经升级了,非常好用,感谢,顺便把openssl升级到3.0了的,可以用纯tls1.3了 
  • meitangdehulu 2022-12-19
    引用 5
    尝试更新openssl后也还是报错

    ./configure: error: SSL modules require the OpenSSL library.
    You can either do not enable the modules, or install the OpenSSL library
    into the system, or build the OpenSSL library statically from the source
    with nginx by using --with-openssl=<path> option.
  • maher 2022-12-26
    引用 6
    准备编译环境
    先把这一大堆依赖安装 

    yum update

    yum install gcc

    yum install -y epel-release  #安装epel源

    yum -y install yum-utils

    wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo #更换 linux yum 数据源的方法

    yum -y install libxml2 libxml2-devel libxslt-devel gd-devel gperftools libuuid-devel libblkid-devel libudev-devel fuse-devel libedit-devel libatomic_ops-devel gcc-c++

    yum -y install gcc openssl openssl-devel pcre-devel zlib zlib-devel

    yum -y install make zlib zlib-devel gcc-c++ libtool openssl openssl-devel 

    yum -y install gcc gcc-c++ autoconf automake make

    yum install gd gd-devel -y

    yum group install 'Development Tools'

    yum install perl-core zlib-devel -y

    下载OpenSSL源码

    wget --no-check-certificate https://www.openssl.org/source/openssl-3.0.5.tar.gz


    tar -xzf openssl-3.0.5.tar.gz

    cd openssl-3.0.5

    ./config --prefix=/usr

    编译&&安装

    make && make install

    ldconfig

    查看安装版本

    openssl version
    OpenSSL 3.0.5 5 Jul 2022
  • 哈辛达 2023-1-2
    引用 7
    高级,不过活整的不太好看,按照lsb 标准来更新活会漂亮很多
  • kavid 2023-2-17
    引用 8
    哈辛达 高级,不过活整的不太好看,按照lsb 标准来更新活会漂亮很多
    有更好的方法,可以说一下吗?
  • kavid 2023-3-3
    引用 9
    sed -e "s|%%PREFIX%%|/etc/nginx|" \
           -e "s|%%PID_PATH%%|/var/run/nginx.pid|" \
           -e "s|%%CONF_PATH%%|/etc/nginx/nginx.conf|" \
           -e "s|%%ERROR_LOG_PATH%%|/var/log/nginx/error.log|" \
           < man/nginx.8 > objs/nginx.8
    make[1]: 离开目录“/root/nginx-1.22.1”


    这个算是完成了吗??
  • kavid 2023-3-3
    引用 10
    第八步 出现如下错误

    make upgrade --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -fPIC' --with-ld-opt='-Wl,-z,relro -Wl,-z,now -pie'make:无法识别的选项“--prefix=/etc/nginx”
    make:无法识别的选项“--sbin-path=/usr/sbin/nginx”
    make:无法识别的选项“--modules-path=/usr/lib64/nginx/modules”
    make:无法识别的选项“--conf-path=/etc/nginx/nginx.conf”
    make:无法识别的选项“--error-log-path=/var/log/nginx/error.log”
    make:无法识别的选项“--http-log-path=/var/log/nginx/access.log”
    make:无法识别的选项“--pid-path=/var/run/nginx.pid”
    make:无法识别的选项“--lock-path=/var/run/nginx.lock”
    make:无法识别的选项“--http-client-body-temp-path=/var/cache/nginx/client_temp”
    make:无法识别的选项“--http-proxy-temp-path=/var/cache/nginx/proxy_temp”
    make:无法识别的选项“--http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp”
    make:无法识别的选项“--http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp”
    make:无法识别的选项“--http-scgi-temp-path=/var/cache/nginx/scgi_temp”
    make:无法识别的选项“--user=nginx”
    make:无法识别的选项“--group=nginx”
    make:无法识别的选项“--with-compat”
    make:无法识别的选项“--with-file-aio”
    make:无法识别的选项“--with-threads”
    make:无法识别的选项“--with-http_addition_module”
    make:无法识别的选项“--with-http_auth_request_module”
    make:无法识别的选项“--with-http_dav_module”
    make:无法识别的选项“--with-http_flv_module”
    make:无法识别的选项“--with-http_gunzip_module”
    make:无法识别的选项“--with-http_gzip_static_module”
    make:无法识别的选项“--with-http_mp4_module”
    make:无法识别的选项“--with-http_random_index_module”
    make:无法识别的选项“--with-http_realip_module”
    make:无法识别的选项“--with-http_secure_link_module”
    make:无法识别的选项“--with-http_slice_module”
    make:无法识别的选项“--with-http_ssl_module”
    make:无法识别的选项“--with-http_stub_status_module”
    make:无法识别的选项“--with-http_sub_module”
    make:无法识别的选项“--with-http_v2_module”
    make:无法识别的选项“--with-mail”
    make:无法识别的选项“--with-mail_ssl_module”
    make:无法识别的选项“--with-stream”
    make:无法识别的选项“--with-stream_realip_module”
    make:无法识别的选项“--with-stream_ssl_module”
    make:无法识别的选项“--with-stream_ssl_preread_module”
    make:无法识别的选项“--with-cc-opt=-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -fPIC”
    make:无法识别的选项“--with-ld-opt=-Wl,-z,relro -Wl,-z,now -pie”
    用法:make [选项] [目标] ...
    选项:
      -b, -m                      忽略兼容性。
      -B, --always-make           无条件 make 所有目标。
      -C DIRECTORY, --directory=DIRECTORY
                                  在执行钱先切换到 DIRECTORY 目录。
      -d                          打印大量调试信息。
      --debug[=FLAGS]             打印各种调试信息。
      -e, --environment-overrides
                                  环境变量覆盖 makefile 中的变量。
      --eval=STRING               Evaluate STRING as a makefile statement.
      -f FILE, --file=FILE, --makefile=FILE
                                  从 FILE 中读入 makefile。
      -h, --help                  打印该消息并退出。
      -i, --ignore-errors         Ignore errors from recipes.
      -I DIRECTORY, --include-dir=DIRECTORY
                                  在 DIRECTORY 中搜索被包含的 makefile。
      -j [N], --jobs[=N]          同时允许 N 个任务;无参数表明允许无限个任务。
      -k, --keep-going            当某些目标无法创建时仍然继续。
      -l [N], --load-average[=N], --max-load[=N]
                                  在系统负载高于 N 时不启动多任务。
      -L, --check-symlink-times   使用软链接及软链接目标中修改时间较晚的一个。
      -n, --just-print, --dry-run, --recon
                                  Don't actually run any recipe; just print them.
      -o FILE, --old-file=FILE, --assume-old=FILE
                                  将 FILE 当做很旧,不必重新生成。
      -p, --print-data-base       打印 make 的内部数据库。
      -q, --question              Run no recipe; exit status says if up to date.
      -r, --no-builtin-rules      禁用内置隐含规则。
      -R, --no-builtin-variables  禁用内置变量设置。
      -s, --silent, --quiet       Don't echo recipes.
      -S, --no-keep-going, --stop
                                  关闭 -k。
      -t, --touch                 touch 目标而不是重新创建它们。
      -v, --version               打印 make 的版本号并退出。
      -w, --print-directory       打印当前目录。
      --no-print-directory        关闭 -w,即使 -w 默认开启。
      -W FILE, --what-if=FILE, --new-file=FILE, --assume-new=FILE
                                  将 FILE 当做最新。
      --warn-undefined-variables  当引用未定义变量的时候发出警告。
      --warn-undefined-functions  Warn when an undefined user function is called.

    该程序为 x86_64-redhat-linux-gnu 编译
    报告错误到 <bug-make@gnu.org>
    [root@192 nginx-1.22.1]# make upgrade
    /usr/sbin/nginx -t
    nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
    nginx: configuration file /etc/nginx/nginx.conf test is successful
    kill -USR2 `cat /var/run/nginx.pid`
    sleep 1
    test -f /var/run/nginx.pid.oldbin
    kill -QUIT `cat /var/run/nginx.pid.oldbin`
返回
发新帖