0
這是我的default.conf
。我指定了access.log和error.log路徑。我使用docker來構建它。Nginx的訪問日誌文件路徑
server {
listen 80;
server_name localhost;
root /var/www/html;
index index.html index.php;
charset utf-8;
location/{
try_files $uri $uri/ /index.php?$query_string;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
if ($time_iso8601 ~ "^(\d{4})-(\d{2})-(\d{2})") {
set $year $1;
set $month $2;
set $day $3;
}
access_log /var/log/nginx/test/access-$year-$month-$day.log;
error_log /var/log/nginx/test2/error.log;
sendfile off;
client_max_body_size 100m;
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass php:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_intercept_errors off;
fastcgi_buffer_size 16k;
fastcgi_buffers 4 16k;
}
location ~ /\.ht {
deny all;
}
}
當我建立起來了。我收到了錯誤消息。
nginx_1 | nginx: [emerg] open() "/var/log/nginx/test2/error.log" failed (2: No such file or directory)
如何自動生成文件路徑?這是我的碼頭撰寫人,Github
我知道我需要先創建文件夾。我可以自動生成文件夾嗎? – lighter
不,因爲如果沒有該文件夾,nginx將無法啓動。所以要麼你把一個SH文件做到這一點,並啓動nginx。 –