One, Apache access logs do not log static files
Most of the site elements are static files, tablets, CSS, JS, etc., these elements can not be recorded
vim/usr/local/apache2.4/conf/extra/httpd-vhosts.conf//Change to the following
Change the virtual host configuration file to the following:
<virtualhost *:80>
DocumentRoot "/data/wwwroot/www.123.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 "Logs/111.com-access_log" combined env=!img
</VirtualHost>
Reload config file-T, graceful
Mkdir/data/wwwroot/www.111.com/images//Create a directory and upload a picture in this directory
Curl-x127.0.0.1:80-i 111.com/images/123.jpg
Tail/usr/local/apache2.4/logs/111.com-access_log
Second, access log cutting
Logs have been recorded one day will be full of the entire disk, so it is necessary to let it automatically cut, and delete the old log files
Change the virtual host configuration file to the following:
Vim/usr/local/apache2.4/conf/extra/httpd-vhosts.conf
<virtualhost *: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
</VirtualHost>
Reload config file-T, graceful
Ls/usr/local/apache2.4/logs
Third, static element expiration time
When a browser accesses a picture of a Web site, it caches the static files on the local computer so that it does not have to be downloaded remotely at the next visit.
Add configuration
<ifmodule mod_expires.c>
Expiresactive on//switch to turn on the function
Expiresbytype image/gif "Access plus 1 days"
Expiresbytype image/jpeg "Access plus hours"
Expiresbytype image/png "Access plus hours"
Expiresbytype text/css "Now plus 2 hour"
Expiresbytype Application/x-javascript "now plus 2 hours"
Expiresbytype Application/javascript "now plus 2 hours"
Expiresbytype Application/x-shockwave-flash "now plus 2 hours"
ExpiresDefault "now plus 0 min"
</IfModule>
Need Expires_module
Curl test, see Cache-control:max-age
Linux centos7 VMware Apache access logs do not log static files, access log cuts, static element expiration times