【问题标题】:changing log file location for nginx更改 nginx 的日志文件位置
【发布时间】:2018-10-12 04:38:05
【问题描述】:

我正在尝试对 nginx.conf 文件进行简单的更改。我尝试将错误日志的位置从/var/log/nginx/error.log 更改为/path/to/directory/error.log。但是当我尝试重新启动 nginx 服务时,该服务无法启动,当我检查其状态时,会显示以下日志。

nginx: [emerg] open() "/path/to/directory/error.log" failed (13: Permission denied)

我尝试更改目录的所有权,但仍然失败。任何帮助将不胜感激。
谢谢

【问题讨论】:

  • 确保文件夹的所有者与 nginx 用户匹配。
  • 文件夹的所有者与 nginx.conf 文件中定义的所有者匹配。 @TanHongTat

标签: linux nginx server


【解决方案1】:

你的路径目录不属于 NGINX 用户,它是 www-data,所以你需要运行

chown -R www-data:www-data /path/to/log/file

【讨论】:

  • /var/log/nginx/error.log 中的默认日志文件归nginx 用户而非www-data 所有。我将/path/to/directory/error.log 的所有权更改为nginx,但仍然没有任何改变。
  • nginx 不是用户。如果是 nginx,你的 websuser 是 www-data
猜你喜欢
  • 2015-04-15
  • 2018-02-07
  • 2015-07-22
  • 1970-01-01
  • 2016-07-06
  • 2019-04-18
  • 2016-07-08
  • 1970-01-01
  • 2019-03-17
相关资源
最近更新 更多