高手来瞅瞅, centos 下, nginx 安装后,修改日志路径,造成无法启动

2017-03-23 23:29:03 +08:00
 colordog

高手们给看看啊,这个是报错内容

3 月 23 11:23:59 localhost.localdomain systemd[1]: Starting nginx - high performance web server...
3 月 23 11:23:59 localhost.localdomain nginx[30550]: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
3 月 23 11:23:59 localhost.localdomain nginx[30550]: nginx: [emerg] open() "/home/www/log/error.log" failed (13: Permission denied)
3 月 23 11:23:59 localhost.localdomain nginx[30550]: nginx: configuration file /etc/nginx/nginx.conf test failed
3 月 23 11:23:59 localhost.localdomain systemd[1]: nginx.service: control process exited, code=exited status=1
3 月 23 11:23:59 localhost.localdomain systemd[1]: Failed to start nginx - high performance web server.
3 月 23 11:23:59 localhost.localdomain systemd[1]: Unit nginx.service entered failed state.
3 月 23 11:23:59 localhost.localdomain systemd[1]: nginx.service failed.

下面是 nginx.conf 文件内容

================== 配置文件==================== user apache;
worker_processes 1;

error_log /home/www/log/error.log warn;
pid /var/run/nginx.pid;

events {
worker_connections 1024;
}

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

log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                  '$status $body_bytes_sent "$http_referer" '
                  '"$http_user_agent" "$http_x_forwarded_for"';

access_log  /home/www/log/access.log  main;

sendfile        on;
#tcp_nopush     on;

keepalive_timeout  65;

gzip  on;

include /etc/nginx/conf.d/*.conf;

}

======================配置文件=========================

已知 /home/www/log 存在,并且属于 apche 用户名,用户组,为了测试权限,并且尝试给了 777 ,仍旧有问题

这个问题感觉装系统有时候会发生,有时候又没事,很奇怪, apache 也是,其他软件没遇到,感觉好奇怪。

10639 次点击
所在节点    NGINX
23 条回复
Phant0m
2017-03-24 00:07:47 +08:00
@colordog setenforce 0 只是临时关闭,如果不会配置 selinux 那就在配置文件里 disable ,省的下次重启的时候又出问题
colordog
2017-03-24 00:09:01 +08:00
@kmahyyg
@Phant0m
@zsz 再次对大家表示感谢。
yunshansimon
2017-03-24 00:10:28 +08:00
如果权限是 777 都不行,就肯定是 apparmor 的锅了。 apparmor 配置了相关服务程序的访问权限。具体配置文件在 /etc/apparmor.d 里面,具体如何配置,可以 man 来查,只要打开相应目录相应文件的写许可就好了。 apparmor 主要是防止非法程序冒充系统服务获取 root 权限后作恶的。主要的系统服务都有配置,里面具体写清楚了可读写的文件和端口。让客户可以放心让系统服务获取 root 权限。就算恶意程序冒充服务启动了,也最多访问一些 log 文件和服务端口。如果大家对别人的程序不放心,也可以为这个程序写 apparmor 配置,保证它不能访问你不许可的资源。

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/349884

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX