问题原文
原帖链接 · gacopu · CC BY-SA 4.0
I'm running nginx using common user not root. I have nginx installed system-wide, but have nginx.conf in HOME.
$HOME/nginx/nginx.conf
worker_processes 1;
error_log /home/worker/nginx/log/nginx/error.log warn;
pid /home/worker/nginx/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
access_log /home/worker/nginx/log/nginx/access.log;
server {
listen 8080;
root /home/worker/nginx/data;
}
}
start nginx
$ nginx -c /home/worker/nginx/nginx.conf
nginx: [alert] could not open error log file: open() "/var/log/nginx/error.log" failed (13: Permission denied)
As you can see in the nginx.conf, I have defined error_log, but I still got the warning message:
nginx: [alert] could not open error log file: open() "/var/log/nginx/error.log" failed (13: Permission denied)
nginx itself works, just want to remove this warning message, how can I do that?
社区高分解答
原帖链接 · Vincent Stragier · CC BY-SA 4.0
I'm late to the party, but I've had this issue for another reason. I simply added the access rights to the folder and files for nginx (www-data user in my case):
sudo chown -R www-data:www-data /var/log/nginx
I've actually removed the whole folder and log file and recreated them:
sudo rm -rf /var/log/nginx
sudo mkdir /var/log/nginx
sudo touch /var/log/nginx/error.log
sudo chown -R www-data:www-data /var/log/nginx
Maybe there is a more elegant solution.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
