简体   繁体   English

更改nginx的日志文件位置

[英]changing log file location for nginx

I am trying out simple changes in nginx.conf file. 我正在尝试nginx.conf文件中的简单更改。 I tried changing the location of error log from /var/log/nginx/error.log to /path/to/directory/error.log . 我尝试将错误日志的位置从/var/log/nginx/error.log更改为/path/to/directory/error.log But when I try restarting the nginx service, the service fails to startup and when I check its status, following log shows up. 但是,当我尝试重新启动Nginx服务时,该服务无法启动,并且当我检查其状态时,将显示以下日志。

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

I tried changing ownership of the directory but still it fails. 我尝试更改目录的所有权,但仍然失败。 Any help would be highly appreciated. 任何帮助将不胜感激。
Thank you 谢谢

Your path directory is not owned by NGINX user which is www-data so you need to run 您的路径目录不是NGINX用户所有,它是www-data,因此您需要运行

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM