[[email protected] nginx]# nginx -t


nginx: [emerg] unknown log format "main" in /usr/local/nginx/conf/nginx.conf:27
nginx: configuration file /usr/local/nginx/conf/nginx.conf test failed
开起日志时:

access_log  logs/access.log  main;

一定要开起 main 日志格式

如:

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

nginx 常见的错误总结

 

ngxtop 起动失败

[[email protected] /]# ngxtop -c  /usr/local/nginx/conf/nginx.conf
Error: Access log file is not provided and ngxtop cannot detect it from your config file (/usr/local/nginx/conf/nginx.conf).

添加 nginx 日志

如:

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

  
     access_log  logs/access.log  main;
 


 

相关文章: