This morning, a buddy ran to say that the website card was dying, and mysql often got stuck. Df-h: The partition space is full. the access log is too large, and the increase speed is quite scary. solution: Modify the nginx configuration file, access_log. Access logs only record accesses to html, images, css, js, and other files of the PHP file type. add
This morning, a buddy ran to say that the website card was dying, and mysql often got stuck.
Df-H: The partition space is full.
The access log is too large, and the increase speed is quite scary.
Solution:
Modify the nginx configuration file, access_log. Access logs are only recorded.PhpFile. Html 'target = '_ blank'>File TypeOf
Access to html, images, css, js, and other files is not recorded.
Add oneCrontabTask to regularly clear the log Content.
Specific implementation process:
1. Find the default installation path of nginx:/usr/local/nginx/
The directory contains conf logs sbin and other directories.
#Cd/Usr/local/nginx
# Cd conf/vhost // the configuration files of each site are stored in this directory
# Vim linuxso.com. conf
LoCatIon ~ . * \. (Gif | jpg | jpeg | png | bmp | swf) $
{
ExPires 30d; access_log off; // adding this line will not record these file types}
Location ~ . * \. (Js | css )? $ {Expires 12 h; access_log off; // records are not allowed}
Location ~ . * \. (Html | htm) $ // This part is not originally available. We only record access to the PHP file. {Access_log off;} Then, check the bottom line access_log/var/log/linuxso. log/var/www/linuxso; record/var/log/linuxso. the path where logs are stored must be followed by a regular log clearing script. After the modification is complete, run the/usr/local/nginx/sbin/nginx-s reload command to restart nginx. After the modification is completed, the log growth speed will obviously slow down, but it will continue to grow, there will also be a full day of space. 2. Write a simple script to regularly clear logs. # Vim/root/cleanlog. sh write
#/Bin/bash
/Bin/
Rm-Rf/var/log/linuxso. log
/Usr/local/nginx/sbin/nginx-s reload
# Crontab-e 0 0 ***/root/cleanlog. sh // This is cleared once every night at. Set the clearing Frequency Based on your situation.