Linux notes: apache configuration and log-Linux Enterprise Application-Linux server application information. For details, refer to the following section. Alibaba Cloud handled apache configuration today:
1. Set Environment Variables
2. Handling leeching Methods
3. Separate and save logs
1. Set Environment Variables
In apache, you can use regular expressions to determine many variables, and then set another variable for later configuration.
For example, you need to determine whether the user accesses a folder and set a variable record:
SetEnvIfNoCase Request_URI "^ \/aslibra" ISSTART = 1
SetEnvIfNoCase is case-insensitive.
Request_URI matches "^ \/aslibra"
If yes, ISSTART = 1, otherwise it is not 1
In addition, for logs that do not record images, you can find the file path and set the variables for later use:
SetEnv NOFILES 1
CustomLog logs/access_log combined env =! NOFILES
2. Handling leeching
The referrer method is used to determine whether to process leeching. See the following example:
Order Allow, Deny
Allow from all
Deny from env = aaa
The above is to determine the source, and then do not allow this domain name
3. Log Segmentation
You can use cronolog to process log segmentation.
Installation is easier.
Definition Format:
LogFormat "% h % l % u % t \" % r \ "%> s % B \" % {Referer} I \ "\" % {User-Agent} I \ "" combined
LogFormat "% h % l % u % t \" % r \ "%> s % B" common
LogFormat "% {Referer} I-> % U" referer
LogFormat "% {User-agent} I" agent
LogFormat "% h % {% T} t \" % r \ "% {cookiename} C" record
The preceding defines the log format. You can define many log formats for subsequent log usage.
For example, if you want to collect cookies (% {cookiename} C) and custom time formats (% {% T} t ), you can use the record-like method above.
CustomLog "|/Data/apps/cronolog/sbin/cronolog/Data/weblog/% Y/% m/% d/www.aslibra.com. % m % d % H" record
CustomLog "|/Data/apps/cronolog/sbin/cronolog/Data/weblog/% Y/% m/% d/aslibra.com. % m % d % H" combined
In the preceding example, cronolog is called to store logs. The following parameters are custom log formats.
Of course, you can also customize logs that record many conditions. For example, you only need to record the requests starting with/aslibra:
SetEnvIfNoCase Request_URI "^ \/aslibra" ISSTART = 1
CustomLog "|/Data/apps/cronolog/sbin/cronolog/Data/weblog/% Y/% m/% d/aslibra.com. % m % d % H" record env = ISSTART
Several mmlogs can be recorded together, and so on.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.