search

Home  >  Q&A  >  body text

nginx prompts 403 when starting access

After installing nginx, I set the owner of sbin/nginx to root and suid permissions to monitor port 80.

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

But after startup, when accessing localhost port 80, an error is reported: 403 Forbidden

nginx related configuration file contents are as follows:

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;
        }

The error log information is:

[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/"

The permissions of the html directory are as follows, and there is a corresponding index file in this directory

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

Excuse me, what is the problem? Baidu later said it was a permissions issue, but I can’t fix it no matter how I change it?
My system is mac.

習慣沉默習慣沉默2800 days ago581

reply all(3)I'll reply

  • 高洛峰

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

    What are the permissions of your index.html file? It may be that you have not given permissions to the files in the folder.

    reply
    0
  • 我想大声告诉你

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

    Add user root to the header of the nginx configuration file; try it, if it doesn’t work, check what the user and group are for the files in your html directory? Then try changing the startup user to the user to which the directory belongs.

    reply
    0
  • 大家讲道理

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

    Try turning off the firewall first.
    If it doesn’t work, turn off the SELinux service as well

    reply
    0
  • Cancelreply