1

みんな。別のフォルダーにあるログへのシンボリック リンクがいくつかあります。

drwxr-xr-x 2 root root 4096 Sep 28 14:00 .
drwxr-xr-x 4 root root 4096 Sep 28 12:34 ..
lrwxrwxrwx 1 root root   38 Sep 28 13:24 default.access.log -> /path/to/default/access/log
lrwxrwxrwx 1 root root   37 Sep 28 13:24 default.error.log -> /path/to/default/error/log
lrwxrwxrwx 1 root root   26 Sep 28 14:00 fpm.error.log -> /path/to/php/fpm/error/log
-rw-r--r-- 1 root root   50 Sep 28 13:50 .htpasswd
lrwxrwxrwx 1 root root   37 Sep 28 13:24 images.access.log -> /path/to/images/access/log;
lrwxrwxrwx 1 root root   36 Sep 28 13:24 images.error.log -> /path/to/images/error/log;

このファイルをurlで見たいです。私のnginx設定:

server {
    listen 80;
    server_name servername;

    root /path/to/root;
    charset UTF-8;

    access_log /path/to/access/log;
    error_log /path/to/error/log;

    location ~ \.htpasswd$ {
        deny all;
    }

    location ~* \.log$ {
        expires epoch;
        log_not_found off;
        add_header  Content-Type    text/plain;
        auth_basic  "Restricted";
        auth_basic_user_file    /path/to/htpasswd;
    }

    location  /  {
        autoindex  on;
        auth_basic  "Restricted";
        auth_basic_user_file    /path/to/htpasswd;
    }
}

正しく動作しますが、次の 4 つのファイルしか表示されません。

default.access.log        28-Sep-2013 14:19        3431596
default.error.log         28-Sep-2013 13:40            728
images.access.log         28-Sep-2013 14:18         415324
images.error.log          28-Sep-2013 12:05              0

私の間違いはどこですか?前もって感謝します。

4

2 に答える 2

1

nginx ユーザーが不足しているファイルを読み取れることを確認しましたか?

fpm.error.log -> /path/to/php/fpm/error/log

すべての親パスに対する読み取り権限も必要になることに注意してください。

于 2013-09-28T18:01:48.247 に答える
0

これは非常に古いものですが、ラベルが正しく設定されていない場合、SELinux または apparmour が原因である可能性もあります。可能であれば setenforce 0 をテストします。それ以外の場合は、ラベルが正しいことを確認してください。

sudo chcon -Rt httpd_sys_content_t /your/path
于 2020-12-15T14:40:58.120 に答える