更改 Nginx 日志文件位置

Changing Nginx Log File Location

我无法对要使用的 /etc/nginx/nginx.conf http 块进行任何更改。我从最简单的事情开始——我想将 access.log 的名称修改为其他名称(即 a.log)。这是一个普通的 nginx 安装(还没有自定义配置文件)。这是我所知道的:

这是我的 nginx.conf 文件的片段:

user www-data;
worker_processes 4;
pid /run/nginx.pid;

events {
        worker_connections 768;
}

http {
        include /etc/nginx/mime.types;
        default_type application/octet-stream;

        access_log /var/log/nginx/a.log;
        #....
}

是否像我修改一个被其他配置文件覆盖的 http 块一样简单?感谢您的帮助。

你的access_log不也是在服务器块中定义的吗?查看 nginx/sites-enabled/ 中的默认配置。 在这种情况下,http 块中的值被较低块中的值覆盖。