nginx: [warn] the “log_format” directive may be used only on “http” level ...解决办法

新开了一个vps,装了最新的nginx 1.0.2版本,将原来的虚拟主机配置直接拿过来.用nginx -t 测试语法的时候,发现提示以下警告信息

[root@centos nginx]# ./sbin/nginx -t
nginx: [warn] the “log_format” directive may be used only on “http” level in /usr/local/nginx/conf/vhosts/bbs.conf:62

解决办法如下:

将/usr/local/nginx/conf/nginx.conf 里server段里的下面代码移出放到该server段的前面即可。

log_format  access  ‘$remote_addr – $remote_user [$time_local] “$request” ‘
‘$status $body_bytes_sent “$http_referer” ‘
‘”$http_user_agent” $http_x_forwarded_for’;

如果有其的虚拟主机开启了日志,也按上面的要求移出server段放在server段的前面即可。

/usr/local/nginx/sbin/nginx -t 测试一下,没有warn警告信息了。

[root@centos vhosts]# ../../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
[root@centos vhosts]#

9 thoughts on “nginx: [warn] the “log_format” directive may be used only on “http” level ...解决办法

  1. Pingback: http://edukacjapoliceum.pl/wiesz-co-jesz-2728.php

  2. Pingback: Mazlo

  3. Pingback: w88

  4. Pingback: p4551#blog o marketingu

  5. Pingback: 바카라

  6. Pingback: +18

  7. Pingback: dang ky m88.com

  8. Pingback: satta king

  9. Pingback: pest control

Comments are closed.