nginx编译及安装问题集锦[建议收藏] 您所在的位置:网站首页 nginx编译安装如何启动 nginx编译及安装问题集锦[建议收藏]

nginx编译及安装问题集锦[建议收藏]

#nginx编译及安装问题集锦[建议收藏]| 来源: 网络整理| 查看: 265

​目录

问题一、error: the HTTP rewrite module requires the PCRE library.

问题二、error: the HTTP gzip module requires the zlib library.

问题三、invalid PID number "" in "/apps/srv/nginx1.18/logs/nginx.pid"

问题四、unknown directive "ssl_certificate"

问题五、open() "/usr/local/nginx/logs/error.log" failed (13: Permission denied)

问题一、error: the HTTP rewrite module requires the PCRE library.

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

解决:报错的原因是缺少HTTP重写模块的PCRE库,解决方式也非常简单,我们只需要安装HTTP重写模块缺少的PCRE库就行啦,具体的安装命令如下:

yum -y install pcre-devel

截图:

(注意,如果权限不够的话,记得使用sudo提升执行权限)

问题二、error: the HTTP gzip module requires the zlib library.

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

解决:报错原因是HTTP的gzip模块缺少对应的zlib库,我们执行如下命令进行安装即可!

yum install -y zlib-devel

截图:

问题三、invalid PID number "" in "/apps/srv/nginx1.18/logs/nginx.pid"

2021/06/02 14:04:11 [notice] 21603#0: signal process started2021/06/02 14:04:11 [error] 21603#0: invalid PID number "" in "/apps/srv/nginx1.18/logs/nginx.pid"

解决:

没有找到PID对应的nginx进程,所以,如果我们想重启nginx服务的话是有问题的。

我们可以直接运行如下命令启动nginx服务:

./nginx

而不是使用:

./nginx -s reload

当然还有另外一种可能,就是已经存在nginx服务干扰了新服务启动,我们可以使用如下命令查看当前nginx服务的运行状态:

ps -aux | grep nginx

然后,根据PID,干掉对应的nginx服务,再重新启动nginx服务。 

kill -9 pid

截图:

问题四、unknown directive "ssl_certificate"

nginx: [alert] could not open error log file: open() "/usr/local/nginx/logs/error.log" failed (13: Permission denied)2021/06/02 14:23:02 [emerg] 21702#0: unknown directive "ssl_certificate" in /etc/nginx/conf.d/test-oss-01.test.cn.conf:21

解决:

比较常见的原因是证书路径不对或者编译nginx过程中没有指定ssl模块。

如果是前者的话,我们可以修改 test-oss-01.test.cn.conf 配置文件中引用的 *.crt 和 *.key 的路径。

如果是后者的话,我们可以使用如下命令设置编译选项,再执行 make 命令重新编译。

./configure --with-http_ssl_module  //重新添加这个ssl模块

截图:

问题五、open() "/usr/local/nginx/logs/error.log" failed (13: Permission denied)

nginx: [alert] could not open error log file: open() "/usr/local/nginx/logs/error.log" failed (13: Permission denied)

解决:

执行命令前边增加sudo即可!

其实,Nginx的编译安装还有很多别的问题,本人先总结这么多,如果后续有遇到新的问题,会再继续在文中补充!也欢迎大家评论留言,需要解决哪些问题,请告诉我!



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有