Nginx编译安装时常见错误分析
2016-01-10 16:34
711 查看
本篇文章主要是关于Nginx在编译安装时,可能出现的错误的解决方法。
1 Nginx启动脚本错误:env: /etc/init.d/nginx: No such file or directory
明明上传了Nginx服务控制脚本
解决方法:启动脚本的格式有问题,例如该脚本是dos格式,在Linux系统是中无法识别的。可以通过vim打开该文件,如果可以看到出现
2 启动Nginx服务失败
安装完Nginx后,执行命令
解决方法:主要通过命令
很明显是由于下面这个错误,导致Nginx服务启动失败。
这种错误一般都是目录不存在或者权限不足,所以直接执行下面两条命令即可。
3 启动Nginx服务时,界面卡住
在敲入命令
解决方法:可能是Nginx服务控制脚本(/etc/init.d/nginx)代码不正确,推荐使用文章 《Nginx服务启动、停止和重启等操作的SHELL脚本》 中的shell脚本。最后再重新执行下面的脚本即可。
还有一种在启动Nginx服务时,终端界面会卡住的情况:那就是Nginx的配置文件
4 Compilation failed in require或者perl_parse() failed
在使用命令
然后使用命令
解决方法:从图中可以看出由于
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 start Starting 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 stop Stopping 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.conf nginx 7798 0.0 0.3 86656 3380 ? S 21:14 0:00 nginx: worker process root 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解决。
相关文章推荐
- phpstudy搭建nginx+php服务器显示php网页
- nginx开机自启动
- Nginx-start
- Nginx
- How To Install and Configure Django with Postgres, Nginx, and Gunicorn
- mac学习笔记:brew 安装nginx
- 使用gdb调试Nginx worker进程
- nginx rewrite 参数和例子
- nginx 安装
- nginx rewrite 参数和例子
- nginx处理问题笔记
- nginx处理问题笔记
- LNMP服务器安装配置(Rhel+Nginx+PHP+MySQL)
- 安装nginx踩到的坑
- nginx负载均衡配置
- linux下rpm安装nginx
- linux下源码安装nginx
- Nginx简介
- Nginx+php-fpm 502 504问题
- 让Nginx支持pathinfo