2016-02-21 00:10 阅读 260


in /usr/local/nginx/logs/ I have a huge www.access.log file.

It grows undefinitely (last time I truncated it was 3.5 GB) with a new log entry every time a php script is called.

Every line looks like this:

- -  21/Feb/2016:00:59:09 +0100 "GET /index.php" 200 /absoulute-path/index.php 10,373 1280 96,40%

The file is written by php-fpm process

Browsing thru the various configuration files (nginx, php.ini....) I cannot find the directive to write logs to that file.

How can I disable it?

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

3条回答 默认 最新

  • 已采纳
    dqz7636 dqz7636 2016-02-21 02:02

    Given the format and the informations provided in the sample log entry posted in the question the huge log file has nothing (directly) to do with nginx nor with its configuration files, despite it's located in .../nginx/logs/

    That ....access.log file is written by php-fpm worker processes when a specific option is set into php-fpm's configuration file php-fpm.conf

    The file (on my server) is located into /etc/

    At some point in the configuration file there is:

    ; The access log file
    ; Default: not set
    ; access.log = /usr/local/nginx/logs/$pool.access.log

    By default that option is not set and should remain unset; as far as I know the log file it produces is used to test php-fpm proper operation.

    If the line is uncommented by removing the semicolon...

    ; The access log file
    ; Default: not set
    access.log = /usr/local/nginx/logs/$pool.access.log

    ...then a .access.log file prefixed with the pool name (www in the case exposed in the question) is generated. And it grows quickly as each time a php script is run due to a request a new log entry is appended.

    点赞 评论 复制链接分享
  • douyu9433 douyu9433 2016-02-21 00:22

    You have to change the nginx.conf configuration file in this way:

    server {
       access_log off;

    nginx.conf is located in /usr/local/nginx/conf, /usr/local/etc/nginx or /etc/nginx

    Edit: see also How to disable Nginx logging, Disable access logging and ngx_http_log_module

    点赞 评论 复制链接分享
  • dongmou9260 dongmou9260 2016-02-21 01:07

    Disable this is not a good practice .

    Those files can give your very sensitive and informative information about your site visitor .

    You can make some changes to make log files take a smaller space and easy to maintain.

    You can make compression , Log Rotation to avoid filing up disk space and manage your log files .

    Please check this link.

    点赞 评论 复制链接分享