介绍:项目中的CSS、图片、js都是静态文件。一般会将静态文件放到一个单独的目录中,以方便管理。

1. 配置

# vim /usr/local/apache2.4/conf/extra/httpd-vhosts.conf

<VirtualHost *:80>

ServerAdmin webmaster@dummy-host.example.com

DocumentRoot "/usr/local/apache2.4/docs/www.111.com"

ServerName www.111.com

ServerAlias 111.com

ErrorLog "logs/111.com-error_log"

CustomLog "logs/111.com-access_log" common

</VirtualHost>

上传图片文件到image中

# cd /usr/local/apache2.4/docs/www.111.com/

# mkdir image

# ll image/linux.jpg

检查配置信息

# /usr/local/apache2.4/bin/apachectl -t

Syntax OK

# /usr/local/apache2.4/bin/apachectl graceful

# curl -xlocalhost:80 www.111.com/image/linux.jpg -I

查看日志

# tail -f /usr/local/apache2.4/logs/111.com-access_log

打开网页访问111.com/image/linux.jpg

vim /usr/local/apache2.4/conf/extra/httpd-vhosts.conf

<VirtualHost *:80>

ServerAdmin webmaster@dummy-host.example.com

DocumentRoot "/usr/local/apache2.4/docs/www.111.com"

ServerName www.111.com

ServerAlias 111.com

SetEnvIf Request_URI ".*\.gif$" image-request

SetEnvIf Request_URI ".*\.jpg$" image-request

SetEnvIf Request_URI ".*\.png$" image-request

SetEnvIf Request_URI ".*\.bmp$" image-request

SetEnvIf Request_URI ".*\.swf$" image-request

SetEnvIf Request_URI ".*\.js$" image- request

SetEnvIf Request_URI ".*\.css$" image- request

ErrorLog "logs/111.com-error_log"

CustomLog "logs/111.com-access_log" combined env=!image-request

</VirtualHost>

//先定义了一个image-request环境变量,把gif,jpg,png, bmp,swf,js,css等格式文件全归类到此,env=!image-request表示日志记录不为image-request中表示的静态文件。

保存配置后,测试配置文件是否正确,没有错误重新加载服务:

#/usr/local/apache2.4/bin/apachectl -t

Syntax OK

#/usr/local/apache2.4/bin/apachectl graceful

(2)配置验证

# curl -xlocalhost:80 www.111.com/image/linux.jpg -I

另打开一个窗口,查看日志,关于jpg格式的没有访问日志信息

# tailf   ../../logs/111.com-access_log

访问成功

Apache配置 5.访问日志不记录静态文件的更多相关文章

  1. Linux centos7 VMware Apache访问日志不记录静态文件、访问日志切割、静态元素过期时间

    一.Apache访问日志不记录静态文件 网站大多元素为静态文件,如图片.css.js等,这些元素可以不用记录 vim /usr/local/apache2.4/conf/extra/httpd-vho ...

  2. Apache配置 4.访问日志

    (1)介绍 访问日志作用很大,不仅可以记录网站的访问情况,还可以在网站有异常发生时帮助我们定位问题. (2)配置 # vi /usr/local/apache2.4/conf/extra/httpd- ...

  3. Spring Boot 2 配置服务器访问日志

    Tomcat控制台中看到的日志是服务器的日志,而服务器访问日志则是记录服务处理的请求信息. 开发环境:IntelliJ IDEA 2019.2.2Spring Boot版本:2.1.8 1.新建一个名 ...

  4. Apache日志不记录图片文件设置方法和来源日志的配置

    Apache日志不记录图片文件设置方法 <FilesMatch "\.(ico|gif|jpg|swf)">SetEnv IMAG 1</FilesMatch&g ...

  5. LNMP-Nginx配置不记录静态文件、过期时间

    用户访问web网站,通常日志文件会记录很多web站点上的一些静态文件信息,如果长期不处理,日志文件会越来越大,占用的系统资源也越大,此时就需要我们配置不记录静态文件和过期时间,减少日志文件记录过多不必 ...

  6. Nginx访问日志、 Nginx日志切割、静态文件不记录日志和过期时间

    1.Nginx访问日志 配制访问日志:默认定义格式: log_format combined_realip '$remote_addr $http_x_forwarded_for [$time_loc ...

  7. apache配置禁止访问某些文件/目录

    我们来看俩段通常对上传目录设置无权限的列子,配置如下: 代码如下: ? 1 2 3 4 5 6 <Directory "/var/www/upload"> <Fi ...

  8. python统计apache、nginx访问日志IP访问次数并且排序(显示前20条)【转】

    前言:python统计apache.nginx访问日志IP访问次数并且排序(显示前20条).其实用awk+sort等命令可以实现,用awk数组也可以实现,这里只是用python尝试下.   apach ...

  9. Nginx访问日志、日志切割、静态文件不记录日志和过期时间

    6月8日任务 12.10 Nginx访问日志12.11 Nginx日志切割12.12 静态文件不记录日志和过期时间 12.10 Nginx访问日志 除了在主配置文件nginx.conf里定义日志格式外 ...

随机推荐

  1. httprunner(11)运行测试报告

    前言 受益于pytest的集成,HttpRunner v3.x可以使用pytest所有插件,包括pytest-html和allure-pytest,也可以实现这2种方式的报告 内置html报告 pyt ...

  2. [备忘] DevOps 工具上的准备清单(不断补充中……)

    目录 概念 发展历程 工具清单 规划 概念 从字面上来看,"DevOps"一词是由英文 Development(开发)和 Operations (运维)组合而成,但它所代表的理念和 ...

  3. Operating System:操作系统启动总结

    现代操作系统的启动引导过程会有所差异,本文仅针对Intel x86系列作讲解,了解原理即可. 系统引导过程总体介绍 系统引导过程主要由以下几个步骤组成(以硬盘启动为例)1.开机:2.BIOS加电自检( ...

  4. php 文件包含base64读取文件 preg_replace函数

    解题部分题目来源攻防世界web高手进阶区1.拿到题目以后,发现是一个index.php的页面,并且设备-没有显示完全,此位置可疑.2.源代码中发现?page=index,出现page这个get参数,联 ...

  5. Set DSL in Ubuntu 18.04

    Reference Solutions: Ctrl+Atl+t Type nmcli con edit type pppoe con-name ANY_NAME_OF_DSL_YOU_LIKE, wh ...

  6. free video tutorial of Deep Learning

    free video tutorial of Deep Learning AI 深度学习/ 机器学习/人工智能 Deep Learning With Deep Learning – a form of ...

  7. React 17 All In One

    React 17 All In One v17.0.1 https://reactjs.org/blog/2020/10/20/react-v17.html https://reactjs.org/b ...

  8. ES6 ...rest In Action

    ES6 ...rest In Action const arr = [ 2.48, 13.77, 8.64, 20.17, 8.94, 8.07, 12.05, 5.71, 17.54, 2.63 ] ...

  9. js class static property & public class fields & private class fields

    js class static property class static property (public class fields) const log = console.log; class ...

  10. free online markdown editor

    free online markdown editor markdown https://blog.csdn.net/xgqfrms/article/details/50129317 In-brows ...