Nginx编译安装时常见错误分析
来源:互联网 发布:js引用数据类型有哪些 编辑:程序博客网 时间:2024/05/28 15:56
本篇文章主要是关于Nginx在编译安装时,可能出现的错误的解决方法。
1 Nginx启动脚本错误:env: /etc/init.d/nginx: No such file or directory
明明上传了Nginx服务控制脚本 nginx
,但是在执行 service nginx start
命令时,却会报上面的错误。
解决方法:启动脚本的格式有问题,例如该脚本是dos格式,在Linux系统是中无法识别的。可以通过vim打开该文件,如果可以看到出现 ^M
的字符,就可以确定是DOS格式的了。那么可以在vim中执行命令 :%s/\r\+$//e
,将其转换成Unix格式即可。
2 启动Nginx服务失败
安装完Nginx后,执行命令 service nginx start
失败,即无法正常启动Nginx服务。
[root@typecodes init.d]# service nginx startStarting nginx (via systemctl): Warning: Unit file of nginx.service changed on disk, 'systemctl daemon-reload' recommended.Job for nginx.service failed. See 'systemctl status nginx.service' and 'journalctl -xn' for details.[FAILED]
解决方法:主要通过命令 systemctl status nginx.service
来分析,如下图所示。
很明显是由于下面这个错误,导致Nginx服务启动失败。
Apr 11 21:43:07 typecodes nginx[4026]: Starting nginx: nginx: [emerg] mkdir() "/var/tmp/nginx/client/" failed (2: No such file or directory)
这种错误一般都是目录不存在或者权限不足,所以直接执行下面两条命令即可。
[root@typecodes ~]# cd /var/tmp/[root@typecodes ~]# mkdir -p /var/tmp/nginx/{client,proxy,fastcgi,uwsgi,scgi}
3 启动Nginx服务时,界面卡住
在敲入命令 service nginx restart
后,终端界面能卡住,也就是Nginx服务控制脚本 nginx
没有正常执行完毕。在停止Nginx服务后,发现Nginx进程还存在。
#######启动Nginx服务出现警告[root@typecodes init.d]# service nginx restart Restarting nginx (via systemctl): Warning: Unit file of nginx.service changed on disk, 'systemctl daemon-reload' recommended.Restarting nginx (via systemctl): Warning: Unit file of nginx.service changed on disk, 'systemctl daemon-reload' recommended.^C ######终端界面卡住,使用ctrl+c命令强制结束#######停掉Nginx服务[root@typecodes init.d]# service nginx stopStopping nginx (via systemctl): [ OK ]#######查看Nginx进程是否已被停止(可以看到未停止)[root@typecodes init.d]# ps -aux|grep nginx root 7796 0.0 0.2 84184 2044 ? Ss 21:14 0:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.confnginx 7798 0.0 0.3 86656 3380 ? S 21:14 0:00 nginx: worker processroot 7981 0.0 0.0 112644 964 pts/0 S+ 21:19 0:00 grep --color=auto nginx
解决方法:可能是Nginx服务控制脚本(/etc/init.d/nginx)代码不正确,推荐使用文章 《Nginx服务启动、停止和重启等操作的SHELL脚本》 中的shell脚本。最后再重新执行下面的脚本即可。
[root@typecodes init.d]# chkconfig --add nginx[root@typecodes init.d]# chkconfig nginx on[root@typecodes init.d]# service nginx restart
还有一种在启动Nginx服务时,终端界面会卡住的情况:那就是Nginx的配置文件/etc/nginx/nginx.conf
不正确,但是使用 nginx -t
命令显示正常。这种情况只能对nginx.conf文件中的每一个配置进行检查了。
4 Compilation failed in require或者perl_parse() failed
在使用命令 service nginx start
启动Nginx服务时报错,于是通过systemctl status nginx.service
查看具体的错误信息。
然后使用命令 nginx -t
查看配置是否正常,如下图所示,同样报错。
解决方法:从图中可以看出由于 Can't load '/usr/local/lib64/perl5/auto/nginx/nginx.so' for module nginx: /usr/local/lib64/perl5/au...m line 68.
的错误,导致了Nginx在调用函数时失败: perl_parse() failed
。也就是证明是之前没有安装perl依赖包,于是通过执行命令 yum -y install perl-devel perl-ExtUtils-Embed
后,再次编译安装Nginx解决。
- Nginx编译安装时常见错误分析
- PHP编译安装时常见错误解决办法
- g++ 编译 时常见错误
- PHP编译安装时常见错误解决办法,php编译常见错误
- PHP编译安装时常见错误解决办法,php编译常见错误
- 【Android】源码编译 时常见错误
- xcode编译时常见错误之一
- PHP编译configure时常见错误
- PHP编译configure时常见错误
- PHP编译configure时常见错误
- vxworks编译时常见的问题分析
- Archlinux编译第三方软件时常见错误
- 编译Android4.0源码时常见错误及解决办法
- 编译Android4.0源码时常见错误及解决办法
- iOS静态代码分析时常见错误及解决办法
- C编译时常见告警和错误
- 启动hadoop时常见错误
- 使用cocoapods时常见错误
- 烤氏历史第3集:争议网通-资金雄厚的挑战者,负债累累的争议者
- 简易在线投票系统(php)——前端设计(js部分)
- AngularJS进阶(二十六)实现分页操作
- 烤氏历史第4集:TD往事-商用分水岭
- abstract class和interface
- Nginx编译安装时常见错误分析
- 美景、美食、美人——记我的家乡“大别山”!!!
- 在Visual Studio上开发ARM嵌入式软件
- 原型模式(一)
- [数论] 组合数取模 中国剩余定理 Lucas定理
- 菜鸟学习数据结构之用回文问题理解栈
- Eclipse常用设置
- 烤氏历史第5集:小灵通漫游神州记-从贝尔实验室到非典机遇
- 数组与指针