华为云nginx部署

时间:2024-03-01 13:09:14
  • 如果在使用 yum 安装软件包时出现 “Error: GPG check FAILED” 错误,这通常是由于 yum 包管理器无法验证软件包的数字签名而导致的。为了解决这个问题,你可以尝试以下方法:

    禁用 GPG 检查:
    你可以通过在 yum 安装命令中添加 --nogpgcheck 参数来暂时禁用 GPG 检查,例如:

    sudo yum install package-name --nogpgcheck

  • make && make install时出现错误 (隐式的 case 分支穿透警告转换为错误)

    报错信息:
    src/core/ngx_murmurhash.c: 在函数‘ngx_murmur_hash2’中:
    src/core/ngx_murmurhash.c:37:11: 错误:this statement may fall through [-Werror=implicit-fallthrough=]
             h ^= data[2] << 16;
             ~~^~~~~~~~~~~~~~~~
    src/core/ngx_murmurhash.c:38:5: 附注:here
         case 2:
         ^~~~
    src/core/ngx_murmurhash.c:39:11: 错误:this statement may fall through [-Werror=implicit-fallthrough=]
             h ^= data[1] << 8;
             ~~^~~~~~~~~~~~~~~
    src/core/ngx_murmurhash.c:40:5: 附注:here
         case 1:
    

    解决方法:

    这个错误是由于编译器开启了 -Werror=implicit-fallthrough 选项,它会将隐式的 case 分支穿透警告转换为错误。解决这个问题有几种方法:
    
    禁用 -Werror=implicit-fallthrough 选项:
    你可以尝试在编译 Nginx 时禁用 -Werror=implicit-fallthrough 选项,这样编译器就不会将隐式 fallthrough 警告转换为错误。在执行 ./configure 之前,可以尝试设置 CFLAGS 环境变量来禁用该选项,例如:
    
    export CFLAGS="-Wno-error=implicit-fallthrough"
    
    ./configure
    make && make install
    
    请注意,禁用该警告可能会导致在代码中存在真正的 fallthrough 问题而未被发现,因此请谨慎使用此方法。
    
  • 执行“make && make install”命令的时候报错

    src/os/unix/ngx_user.c: 在函数‘ngx_libc_crypt’中:
    src/os/unix/ngx_user.c:35:7: 错误:‘struct crypt_data’没有名为‘current_salt’的成员
         cd.current_salt[0] = ~salt[0];
           ^
    make[1]: *** [objs/Makefile:712:objs/src/os/unix/ngx_user.o] 错误 1
    make[1]: 离开目录“/root/csp/nginx/nginx-1.6.2”
    make: *** [Makefile:8:build] 错误 2
    

    解决方法

    1. 第一步:找到你安装nginx的根目录,进入下面的unix目录,并修改 “ngx_user.c” 文件

      #进入unix目录命令:(需要在nginx的安装根目录下面执行)
      cd  src/os/unix/
      
      #编辑文件命令:
      vim ngx_user.c
      
      #注释
      注释掉36行 /*cd.current_salt[0]=~salt[0];*/
      
    2. 第二步:找到你安装nginx的根目录,进入下面的objs目录,删除Makefile文件中的 “-Werrori ”

      #进入objs目录命令:(需要在nginx的安装根目录下面执行)
      cd objs
      
      #编辑文件
      vim Makefile
      
      删除第三行 CFLAGS = -pipe -0 -W -Wall -Wpointer-arith -Wno-unused-parameter -Werrori -g   中的-Werrori 然后保存退出
      
    3. 第三步:再次执行编译安装命令

      #编译安装命令:(需要在nginx安装的根目录下面执行)
      make && make install