LNMP搭建8:Nginx不记录指定文件类型日志
2017-02-25 12:50
375 查看
在Nginx主配置文件中
[root@cp1 conf]# vim nginx.conf
有关于日志的格式定义如下:
在虚拟主机配置文件中选择日志格式类型定义我们的日志
[root@cp1 conf]# vim vhosts/test.conf
定义访问日志的存放路径和格式
重新加载配置文件:
[root@cp1 conf]# /usr/local/nginx/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@cp1 conf]# /usr/local/nginx/sbin/nginx -s reload
访问几次
[root@cp1 conf]# curl -x127.0.0.1:80 www.test.com -I
HTTP/1.1 301 Moved Permanently
Server: nginx/1.6.2
Date: Thu, 23 Feb 2017 16:39:25 GMT
Content-Type: text/html
Connection: keep-alive
X-Powered-By: PHP/5.4.37
location: forum.php
[root@cp1 conf]# curl -x127.0.0.1:80 www.test.com -I
HTTP/1.1 301 Moved Permanently
Server: nginx/1.6.2
Date: Thu, 23 Feb 2017 16:39:30 GMT
Content-Type: text/html
Connection: keep-alive
X-Powered-By: PHP/5.4.37
location: forum.php
查看产生的日志
[root@cp1 conf]# ls /tmp/access.log
/tmp/access.log
[root@cp1 conf]# cat /tmp/access.log
127.0.0.1 - [24/Feb/2017:00:39:25 +0800]www.test.com "/" 301"-" "curl/7.19.7 (i386-redhat-linux-gnu) libcurl/7.19.7 NSS/3.14.0.0 zlib/1.2.3 libidn/1.18 libssh2/1.4.2"
127.0.0.1 - [24/Feb/2017:00:39:30 +0800]www.test.com "/" 301"-" "curl/7.19.7 (i386-redhat-linux-gnu) libcurl/7.19.7 NSS/3.14.0.0 zlib/1.2.3 libidn/1.18 libssh2/1.4.2"
刷新浏览器之后
[root@cp1 conf]# cat /tmp/access.log
编辑虚拟主机配置文件,设置指定文件类型的访问不记入日志
[root@cp1 conf]# vim vhosts/test.conf
检查错误重启服务
[root@cp1 conf]# /usr/local/nginx/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@cp1 conf]# /usr/local/nginx/sbin/nginx -s reload
先清空日志
[root@cp1 conf]# > /tmp/access.log
刷新浏览器后指定文件类型的访问不记录
[root@cp1 conf]# vim nginx.conf
有关于日志的格式定义如下:
在虚拟主机配置文件中选择日志格式类型定义我们的日志
[root@cp1 conf]# vim vhosts/test.conf
定义访问日志的存放路径和格式
重新加载配置文件:
[root@cp1 conf]# /usr/local/nginx/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@cp1 conf]# /usr/local/nginx/sbin/nginx -s reload
访问几次
[root@cp1 conf]# curl -x127.0.0.1:80 www.test.com -I
HTTP/1.1 301 Moved Permanently
Server: nginx/1.6.2
Date: Thu, 23 Feb 2017 16:39:25 GMT
Content-Type: text/html
Connection: keep-alive
X-Powered-By: PHP/5.4.37
location: forum.php
[root@cp1 conf]# curl -x127.0.0.1:80 www.test.com -I
HTTP/1.1 301 Moved Permanently
Server: nginx/1.6.2
Date: Thu, 23 Feb 2017 16:39:30 GMT
Content-Type: text/html
Connection: keep-alive
X-Powered-By: PHP/5.4.37
location: forum.php
查看产生的日志
[root@cp1 conf]# ls /tmp/access.log
/tmp/access.log
[root@cp1 conf]# cat /tmp/access.log
127.0.0.1 - [24/Feb/2017:00:39:25 +0800]www.test.com "/" 301"-" "curl/7.19.7 (i386-redhat-linux-gnu) libcurl/7.19.7 NSS/3.14.0.0 zlib/1.2.3 libidn/1.18 libssh2/1.4.2"
127.0.0.1 - [24/Feb/2017:00:39:30 +0800]www.test.com "/" 301"-" "curl/7.19.7 (i386-redhat-linux-gnu) libcurl/7.19.7 NSS/3.14.0.0 zlib/1.2.3 libidn/1.18 libssh2/1.4.2"
刷新浏览器之后
[root@cp1 conf]# cat /tmp/access.log
编辑虚拟主机配置文件,设置指定文件类型的访问不记入日志
[root@cp1 conf]# vim vhosts/test.conf
检查错误重启服务
[root@cp1 conf]# /usr/local/nginx/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@cp1 conf]# /usr/local/nginx/sbin/nginx -s reload
先清空日志
[root@cp1 conf]# > /tmp/access.log
刷新浏览器后指定文件类型的访问不记录
相关文章推荐
- LNMP - Nginx不记录指定文件类型日志
- LNMP - nginx不记录指定文件类型日志
- LNMP--Nginx不记录指定文件日志
- nginx不记录指定文件类型的日志
- nginx配置不记录指定文件类型日志
- 1.9 nginx不记录指定文件类型的日志
- nginx不记录指定文件类型日志
- nginx不记录指定文件类型日志
- Nginx不记录指定文件类型的日志
- Nginx 不记录指定文件类型的日志
- Nginx配置——不记录指定文件类型日志
- Apache 不记录指定文件类型的日志――LAMP环境搭建
- nginx不记录指定文件类型日志
- 1.9-nginx不记录指定文件类型日志
- httpd之不记录指定文件类型的日志
- 2.1-Apache不记录指定文件类型日志
- apache不记录指定文件类型日志
- Apache不记录指定文件类型日志---模块
- apache日志切割与不记录指定文件类型日志
- Nginx 指定不产生日志类型(不记录图片日志)