快上网专注成都网站设计 成都网站制作 成都网站建设
成都网站建设公司服务热线:028-86922220

网站建设知识

十年网站开发经验 + 多家企业客户 + 靠谱的建站团队

量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决

【CentOS7架构11】,访问日志切割#171221

hellopasswd

创新互联是一家集网站建设,石柱土家族企业网站建设,石柱土家族品牌网站建设,网站定制,石柱土家族网站建设报价,网络营销,网络优化,石柱土家族网站推广为一体的创新建站企业,帮助传统企业提升企业形象加强企业竞争力。可充分满足这一群体相比中小企业更为丰富、高端、多元的互联网需求。同时我们时刻保持专业、时尚、前沿,时刻以成就客户成长自我,坚持不断学习、思考、沉淀、净化自己,让我们为更多的企业打造出实用型网站。

访问日志切割 日志一直记录总有一天会把整个磁盘占满,所以有必要设置自动切割,并删除旧的日志文件 把虚拟主机配置文件改成如下: :80> DocumentRoot "/data/wwwroot/www.111.com" ServerName www.111.com ServerAlias 111.com SetEnvIf Request_URI "..gif$" img SetEnvIf Request_URI "..jpg$" img SetEnvIf Request_URI "..png$" img SetEnvIf Request_URI "..bmp$" img SetEnvIf Request_URI "..swf$" img SetEnvIf Request_URI "..js$" img SetEnvIf Request_URI "..css$" img CustomLog "|/usr/local/apache2.4/bin/rotatelogs -l logs/111.com-access_%Y%m%d.log 86400" combined env=!img 重新加载配置文件-t,graceful ls /usr/local/apache2.4/logs

[root@localhost 111.com]# vi /usr/local/apache2.4/conf/extra/httpd-vhosts.conf 44 45 RewriteEngine on 46 RewriteCond %{HTTP_HOST} !^111.com$ 47 RewriteRule ^/(.*)$ http://111.com/$1 [R=301,L] 48 49 ErrorLog "logs/111.com-error_log" 50 SetEnvIf Request_URI ".*.gif$" img 51 SetEnvIf Request_URI ".*.jpg$" img 52 SetEnvIf Request_URI ".*.png$" img 53 SetEnvIf Request_URI ".*.bmp$" img 54 SetEnvIf Request_URI ".*.swf$" img 55 SetEnvIf Request_URI ".*.js$" img 56 SetEnvIf Request_URI ".*.css$" img 57 CustomLog "|/usr/local/apache2.4/bin/rotatelogs -l logs/111.com-access_%Y%m%d.log 86400" combined env=!img 58

-l以当前系统切割日志,若不指定以UTC切割,国内为CST,差几个时区 按天记录,换算为秒为86400s

[root@localhost 111.com]# /usr/local/apache2.4/bin/apachectl -t Syntax OK [root@localhost 111.com]# /usr/local/apache2.4/bin/apachectl graceful [root@localhost 111.com]# ls /usr/local/apache2.4/logs/ 111.com-access_log abc.com-access_log access_log httpd.pid 111.com-error_log abc.com-error_log error_log [root@localhost 111.com]# curl -x 127.0.0.1:80 111.com/index.php hello!111.com

[root@localhost 111.com]# cat /usr/local/apache2.4/logs/111.com-access_20171104.log 127.0.0.1 - - [04/Nov/2017:22:30:22 +0800] "GET HTTP://111.com/index.php HTTP/1.1" 200 13 "-" "curl/7.29.0 [root@localhost 111.com]# ls /usr/local/apache2.4/logs/ 111.com-access_20171104.log 111.com-error_log abc.com-error_log error_log 111.com-access_log abc.com-access_log access_log httpd.pid

[root@localhost 111.com]# curl -x 127.0.0.1:80 111.com/1111.png -I HTTP/1.1 200 OK Date: Sat, 04 Nov 2017 14:35:19 GMT Server: Apache/2.4.29 (Unix) PHP/5.6.30 Last-Modified: Sat, 04 Nov 2017 14:35:19 GMT ETag: W/"99ad-560d9271dfe00" Accept-Ranges: bytes Content-Length: 39341 Content-Type: image/png [root@localhost 111.com]# curl -x 127.0.0.1:80 111.com/1111.png1 -I HTTP/1.1 404 Not Found Date: Sat, 04 Nov 2017 14:35:24 GMT Server: Apache/2.4.29 (Unix) PHP/5.6.30 Content-Type: text/html; charset=iso-8859-1 [root@localhost 111.com]# cat /usr/local/apache2.4/logs/111.com-access_20171104.log 127.0.0.1 - - [04/Nov/2017:22:30:22 +0800] "GET HTTP://111.com/index.php HTTP/1.1" 200 13 "-" "curl/7.29.0" 127.0.0.1 - - [04/Nov/2017:22:35:24 +0800] "HEAD HTTP://111.com/1111.png1 HTTP/1.1" 404 - "-" "curl/7.29.0


修改与 171221


标题名称:【CentOS7架构11】,访问日志切割#171221
文章网址:http://6mz.cn/article/cjjeij.html

其他资讯