Nginx 不记录指定文件类型的日志

查看主配置文件:

[root@LHQ vhosts]# vim ../nginx.conf

在配置文件里:

log_format    combined_realip   '$remote_addr $http_x_forwarded_for   [$time_local]'

(日志格式)   (日志名字)           (两个IP,一个自己的IP,一个代理IP)     (时间)

'$host           "$request_uri"             $status'

(域名)   (访问地址/链接)     (状态码)

[root@LHQ vhosts]# vim test.conf

添加红色部分:

server

{

listen 80;

server_name www.test.com www.aaa.com www.bbb.com;

if ($host != 'www.test.com')

{

rewrite ^/(.*)$ http://www.test.com/$1 permanent;

}

index index.html index.htm index.php;

root /data/www;

access_log /tmp/access.log qiangzi;

location ~ .*admin\.php$ {

auth_basic "aminglinux auth";

auth_basic_usre_file /usr/local/nginx/conf/.htpasswd;

include fastcgi_params;

fastcgi_pass unix:/tmp/www.sock;

#fastcgi_pass 127.0.0.1:9000;

fastcgi_index index.php;

fastcgi_param SCRIPT_FILENAME /data/www$fastcgi_script_name;

}

location ~.*\.(gif|jpg|jpeg|png|bmp|swf)$

   {

       access_log off; (不去记录日志)

   }

location ~ \.php$ {

include fastcgi_params;

fastcgi_pass unix:/tmp/www.sock;

#fastcgi_pass 127.0.0.1:9000;

fastcgi_index index.php;

fastcgi_param SCRIPT_FILENAME /data/www$fastcgi_script_name;

}

保存退出

[root@LHQ vhosts]# /usr/local/nginx/sbin/nginx -s reload  (刷新)

[root@LHQ vhosts]# cat /tmp/access.log  (查看日志)