Nginx —— 检查配置文件nginx.conf的正确性命令(-t)

检查配置文件  nginx.conf   文件的正确性命令:

 

1、执行测试命令
[root@J01051386 conf]# /usr/local/nginx/conf/nginx.conf.bak -t

 2、出错如下所示:

/usr/local/nginx/conf/nginx.conf.bak: line 1: worker_processes: command not found
/usr/local/nginx/conf/nginx.conf.bak: line 3: worker_priority: command not found
/usr/local/nginx/conf/nginx.conf.bak: line 5: daemon: command not found
/usr/local/nginx/conf/nginx.conf.bak: line 6: master_process: command not found
/usr/local/nginx/conf/nginx.conf.bak: line 13: events: command not found
/usr/local/nginx/conf/nginx.conf.bak: line 14: accept_mutex: command not found
/usr/local/nginx/conf/nginx.conf.bak: line 15: accept_mutex_delay: command not found
/usr/local/nginx/conf/nginx.conf.bak: line 16: multi_accept: command not found
/usr/local/nginx/conf/nginx.conf.bak: line 17: use: command not found
/usr/local/nginx/conf/nginx.conf.bak: line 18: worker_connections: command not found
/usr/local/nginx/conf/nginx.conf.bak: line 19: syntax error near unexpected token `}'
/usr/local/nginx/conf/nginx.conf.bak: line 19: `}'

3、分析原因:

 仔细检查才发现我起错目录了,正确的启动是在sbin/下执行”./nginx”,

 而我莫名其妙地跑到conf/下面执行这个命令,就会报上面的错误!

4、正确的命令:

[root@J01051386 conf]# /usr/local/nginx/sbin/nginx   -t

 正确的启动是在sbin/下执行”./nginx”,

5、测试配置文件书写正常后,出现的测试结果:

[root@J01051386 conf]# /usr/local/nginx/sbin/nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful

 

很简单的错误,以此记录,不再出错!

    原文作者:杰儿__er
    原文地址: https://blog.csdn.net/weixin_42167759/article/details/86604493
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞