nginx: [emerg] duplicate "log_format" name "access"

nginx在开启多个虚拟主机日志时,会出现如下错误提示:

nginx: [emerg] duplicate "log_format" name "access" in /etc/nginx/sites-enabled/www.exp.com:2

其实就是因为nginx.conf配置文件在多个access_log中使用了同一个log_format访问;

解决方法:在其它虚拟主机配置文件中,将log_format更改为(access_exp)其它名称,如下

#Log Format
   log_format access_exp '$time_iso8601 | $remote_addr | $request | $status | $request_body | $http_referer | $http_user_agent | $http_x_forwarded_for';

   server {
       listen 80;

       root /var/www/exp/web;

      index index.php index.html index.htm;
      server_name www.exp.com;

      # log
      access_log /var/log/nginx/www.exp.com.access.log access_exp;
      error_log /var/log/nginx/www.exp.com.error.log;

      #location /www.exp.com/ {
      。。。。。。。

重新加载nginx的使配置生效 nginx -s reload

你可能感兴趣的:(Linux系统软件)