简体   繁体   中英

disable access logging for specific folder - centos 6 / apache 2.4

I have a bunch of php scripts in a specific folder on one of my domains which are constantly accessed (20+ hits a second) and would like to disable access logging for all of them (the folder). I am using CentOS 6 with Apache 2.4 and have WHM/Cpanel.

I found information on how to do this using environment variables and modifying the host file, but I am not sure how to customize this for my needs.

I want to disable logging for /home/username/public_html/folder1/folder2/ (everything in it).

Here is what I found online to do this (putting this in a vhost include file) :

<IfModule mod_userdir.c> 
    UserDir public_html 
    SetEnvIf Request_URI "/nolog" dontlog
    CustomLog /var/log/apache2/useraccess_log combined env=!dontlog
</IfModule>

One thing I am confused about is I have a different log location setup. For instance, if I look up /var/cpanel/userdata/username/domain.com it shows this at the top :

customlog: 
  - 
    format: combined
    target: /usr/local/apache/domlogs/domain.com
  - 
    format: "\"%{%s}t %I .\\n%{%s}t %O .\""
    target: /usr/local/apache/domlogs/domain.com-bytes_log
documentroot: /home/username/public_html
group: username
hascgi: 0
homedir: /home/username

Given the different log location how would I implement this? While I am at it I wouldn't mind disabling the logging for the bytes-log as well for this folder. This is too much logging constantly happening which would not be useful to me at all given how much often they are accessed.

'username' and 'domain.com' represent their actual values in the above.

By default cPanel/WHM stores the access logs for the cPanel accounts (domains/sites/etc) in /usr/local/apache/domlogs/ . That means that all the requests for that site are logged in that file (including the requests from folder1, folder2 etc).

You could try something like this:

Create an .htaccess file in /home/username/public_html/folder1/folder2/ with the content from bellow:

<IfModule mod_userdir.c> 
    UserDir public_html 
    SetEnvIf Request_URI "/nolog" dontlog
    CustomLog /usr/local/apache/domlogs/domain.com combined env=!dontlog
</IfModule>

See if that works (basically it should allow logging but exclude the requests from the files from folder1, folder2 etc).

If that doesn't work then you could edit /var/cpanel/userdata/username/domain.com and comment the bytes_log line and the access_log line. That should completely disable access logging of http requests for that domain. You might need to restart httpd and cpanel service for the changes to take effect.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM