首页  >  问答  >  正文

nginx启动访问时提示403

我安装nginx后给sbin/nginx设置了属主为root,和suid权限,以便监听80端口。

chown root sbin/nginx
chmod u+s sbin/nginx

但是启动后访问localhost 80端口报错: 403 Forbidden

nginx相关配置文件内容如下:

server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;
        charset utf-8;

        #access_log  logs/host.access.log  main;

        location / {
            root   html;
            index  index.html index.htm;
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

错误日志信息为:

[error] 4633#0: *1 open() "nginx/html/favicon.ico" failed (13: Permission denied), client: 127.0.0.1, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "localhost", referrer: "http://localhost/"

html目录的权限如下,该目录下有对应的index文件

drwxrwxrwx@  4 xxxxx  staff  136 Nov 16 21:16 html

请问这是什么问题,百度之后说是权限问题,可我怎么改也解决不了啊?
我的系统是mac。

習慣沉默習慣沉默2714 天前524

全部回复(3)我来回复

  • 高洛峰

    高洛峰2017-05-16 17:14:19

    你的index.html文件的权限是什么呀,可能是你没给文件夹内的文件权限。

    回复
    0
  • 我想大声告诉你

    我想大声告诉你2017-05-16 17:14:19

    在nginx配置文件头部加上user root; 试试看,不行的话 看看你html目录下文件的用户和组是什么?然后把启动用户改成目录所属的用户试试看。

    回复
    0
  • 大家讲道理

    大家讲道理2017-05-16 17:14:19

    先关防火墙试试看,
    不行就把SELinux服务也关了

    回复
    0
  • 取消回复