LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   Webserver Root Folder Permission denied for Nginx Server Blocks on CentOS 7.2 (https://www.linuxquestions.org/questions/linux-server-73/webserver-root-folder-permission-denied-for-nginx-server-blocks-on-centos-7-2-a-4175585010/)

vgaven 07-19-2016 05:57 AM

Webserver Root Folder Permission denied for Nginx Server Blocks on CentOS 7.2
 
Hi,
I have a problem I have installed nginx on Centos 7 and I get an 403 on frontend and if I run

sudo tail -f /var/log/nginx/error.log

I get an permission denied error

2016/07/18 22:11:47 [error] 32598#32598: *7 "/var/www/example.com/html/index.html" is forbidden (13: Permission denied), client: XX.XXX.XXX.XXX, server: example.com, request: "GET / HTTP/1.1", host: "example.com"

the owner of the directory

/var/www/example.com/html/index.html
is not root, it is a user which I create and give him admin/root priviliges so it can use sudo.

How can I fix that?

###Update

First I am not using apache and I already give the permission

sudo chown -R $USER:$USER /var/www/example.com/html
sudo chmod -R 755 /var/www
logged in as the admin user

and also tried to give nginx the permission (Permission the same for parent directories)

sudo chown -R nignx:nginx /var/www/example.com/html
sudo chmod -R 755 /var/www

Habitual 07-19-2016 07:03 AM

Welcome to LQ!

Please stop abusing chmod/chown until someone who can help you steps up.

bathory 07-19-2016 03:48 PM

Quote:

I get an permission denied error

2016/07/18 22:11:47 [error] 32598#32598: *7 "/var/www/example.com/html/index.html" is forbidden (13: Permission denied), client: XX.XXX.XXX.XXX, server: example.com, request: "GET / HTTP/1.1", host: "example.com"
Most likely a SELinux problem. Check this post to see what you can do

Elizine 07-27-2016 06:02 AM

Webserver Root Folder Permission denied for Nginx Server Blocks on CentOS 7.2
 
SELinux might not be permitting Nginx to proxy to my server. Running the command below might fix the issue.

Code:

/usr/sbin/setsebool httpd_can_network_connect true

huuphang 07-28-2017 04:03 AM

Quote:

Originally Posted by vgaven (Post 5578173)
Hi,
I have a problem I have installed nginx on Centos 7 and I get an 403 on frontend and if I run

sudo tail -f /var/log/nginx/error.log

I get an permission denied error

2016/07/18 22:11:47 [error] 32598#32598: *7 "/var/www/example.com/html/index.html" is forbidden (13: Permission denied), client: XX.XXX.XXX.XXX, server: example.com, request: "GET / HTTP/1.1", host: "example.com"

the owner of the directory

/var/www/example.com/html/index.html
is not root, it is a user which I create and give him admin/root priviliges so it can use sudo.

How can I fix that?

###Update

First I am not using apache and I already give the permission

sudo chown -R $USER:$USER /var/www/example.com/html
sudo chmod -R 755 /var/www
logged in as the admin user

and also tried to give nginx the permission (Permission the same for parent directories)

sudo chown -R nignx:nginx /var/www/example.com/html
sudo chmod -R 755 /var/www

The first, To check selinux
The second, use namei command to check tree permission as bellow
Code:

namei -l /var/www/example.com/html
i hope this will help you
For example, How To Install Wordpress with nginx on CentOS 6


All times are GMT -5. The time now is 09:02 AM.