Ubuntu20.04 nginx 编译、配置错误处理

具体安装教程点这里

配置过程参考了这篇文章

下面主要记录在执行 ./configure 中所遇到的错误。

 第一个问题:

./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option.

 执行下列安装此问题解决。

sudo apt-get install libpcre3 libpcre3-dev

第二个问题:

继续报错

./configure: error: the HTTP gzip module requires the zlib library.
You can either disable the module by using --without-http_gzip_module
option, or install the zlib library into the system, or build the zlib library
statically from the source with nginx by using --with-zlib=<path> option.

根据提示需要安装zlib

按照以下代码操作。

wget http://www.zlib.net/zlib-1.2.11.tar.gz
tar -xzvf zlib-1.2.11.tar.gz
cd zlib-1.2.11
./configure
make
make install

 第三个问题:

./configure: error: SSL modules require the OpenSSL library.

 原因是编译支持https但缺少OpenSSL库文件。
解决办法:

sudo apt-get install openssl-dev

第四个问题

执行make后还是继续报错,查了一下,这个问题一般不是Nginx的版本高就是服务器版本高的问题

src/os/unix/ngx_user.c: In function ‘ngx_libc_crypt’:
src/os/unix/ngx_user.c:26:7: error: ‘struct crypt_data’ has no member named ‘current_salt’
   26 |     cd.current_salt[0] = ~salt[0];
      |       ^

解决办法:
就进去报错目录下(/usr/local/src/nginx-1.14.1/src/os/unix/ngx_user.c),打开指定的报错文件,将报错行注释

在这里插入图片描述

第五个问题

1|cc1: all warnings being treated as errors

找到当前目录下找到objs文件夹,并进入,打开文件Makefile,找到有一下内容的这行:

1 | CFLAGS =  -pipe  -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g

把这行内容中的 “-Werror”去掉

-Werror: gcc将所有的警告当成错误进行处理。

第六个问题:

在配置完https之后,启动nginx时,遇到了如下问题。

nginx: [error] open() “/usr/local/nginx/logs/nginx.pid” failed (2: No such file or directory)

解决方案:网上搜集了一下资料,两种解决方案。

1.nginx.conf的nginx.pid被注释了

进入nginx.conf目录编辑

sudo vim /usr/local/nginx/conf/nginx.conf

将注释取消,在重新启动。

sudo nginx -s reload

 2.没有指定配置目录。完成这一步之后,才重启成功的。

输入来使用指定nginx.conf文件的方式重启nginx(首先保证上面第一种情况的pid没有被注释,否则可能前两次能打开,但是以后还是会报错的)

sudo /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值