nginx:[emerg]无效参数" $ remote_addr - $ remote_user [$ time_local] $ request"在/etc/nginx/nginx.conf:24

时间:2014-09-08 15:01:10

标签: nginx centos unicorn

输出错误我尝试在以下环境中启动nginx,但进展不顺利。

#env
CentOS v6.5
nginx v1.6.1
unicorn v4.8.3

#error message
nginx: [emerg] invalid parameter "$remote_addr - $remote_user [$time_local] $request " in /etc/nginx/nginx.conf:24
nginx: configuration file /etc/nginx/nginx.conf test failed

#nginx.conf
http {

omit code

log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                  '$status $body_bytes_sent "$http_referer" '
                  '"$http_user_agent"';

access_log  /var/log/nginx/access.log  main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent"';

omit code...
}

在nginx.conf中添加了代码

1 个答案:

答案 0 :(得分:0)

您必须在access_log之前设置log_format,而不是使用一个指令。

log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent"';

access_log /var/log/nginx/access.log main;

nginx docs for log settings