403 forbidden error at Nginx

ezdookie

I'm running Nginx on CentOS 6 and I'm always getting 403 Forbidden every time I try to access to my site...

My config file looks like this:

server {
    listen 80;
    server_name mysite.com www.mysite.com;

    location / {
      root /home/mysite/www;
      index index.html;
    }
}

And this is what I found in error.log

[error] 16853#0: *29 open() "/home/mysite/www/index.html" failed (13: Permission denied), client: xxx.xxx.xxx.xxx, server: mysite.com, request: "GET /test.html HTTP/1.1", host: "mysite.com"

I also run "ls -l" to these directories thinking it's about a chmod problem... this is what I got:

ls -l /usr/share/nginx/html (Working)

-rw-r--r-- 1 root root 3652 Apr 26 20:36 index.html

ls -l /home/mysite/www (Not working)

-rw-r--r-- 1 mysite mysite 3652 Apr 26 20:36 index.html

---------------------------------------- EDIT

ls -ld /home/mysite/www

drwxr-xr-x 2 mysite mysite 4096 Jul 20 20:52 /home/mysite/www

ls -ld /home/mysite

drwxr-xr-x 2 mysite mysite 4096 Jul 20 20:52 www

ls -ld /home

drwx------ 4 mysite mysite 4096 Jul 20 18:39 mysite
PP.

You stated:

ls -ld /home
drwx------ 4 mysite mysite 4096 Jul 20 18:39 mysite

If nginx is running as an ordinary user, presumably as something other than "mysite", then it cannot access /home as only the mysite and root users have this permission.

To find out what user nginx is running as type:

ps faxu

.. and search for the nginx process. To get the nginx user just do

ps faxu | grep nginx

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related