13
The problem I am guessing is the fact that your project root
directory is at /root
. The default permissions for /root
are:
drwx------ 14 root root 4096 May 8 12:47 root
As you can see, other users, such as www-data
donβt even have read access to the /root
directory. In Linux FS, if you need to read something at a path/a/b/c
, you need to have read access to each of the folders in that path.
The Nginx worker process runs as user www-data
which is trying to open a file that is rooted at /root
where this user does not have read permissions, and therefore raising a Permission denied (13)
.
See this demo for more detail:
$ cat /root/test2/text.txt
cat: /root/test2/text.txt: Permission denied
$ sudo cat /root/test2/test.txt
A
$ sudo ls -la /root/ | grep test2
drwxrwxrwx 2 root root 4096 May 24 02:04 test2
Hope this makes sense. The solution would be on of the following:
- Run nginx workers as root (not recommended)
- Move your project directory to a location that is designed to be accessed by multiple users such as
/usr/local/share
or/var/www/
(recommended)
1
I have the same problem. My nginx server on Centos 7.6 canβt access to static folder in path /home/user/app/mysyte/static/
. In /var/log/nginx/error.log
same error open() "/home/user/app/mysyte/static/*.css" failed (13: Permission denied)
For solving this problem look at this page issue 2
- [Django]-Django modelfield, how do I get the actual value?
- [Django]-Deploy Django\Tornado on Heroku
- [Django]-Pass a lazy translation string including variable to function in Django
- [Django]-Django: How to avoid duplicated html id for showing field twice in the same form?
0
i was running into the same problem and i found this answer useful!
Nginx connet to .sock failed (13:Permission denied) β 502 bad gateway
What I simply did was changing the name of the user on the first line in /etc/nginx/nginx.conf file.
In my case the default user was www-data and I changed it to my root machine username.
- [Django]-Django admin β Wrong model object at edit page
- [Django]-Caught ViewDoesNotExist while rendering
- [Django]-'MyModel' object is not iterable
- [Django]-How to mark string for translation in jinja2 using trans blocks
0
As @rtindru said the solution to the problem is to move your project directory to a location that is designed to be accessed by multiple users such as /usr/local/share or /var/www/.
Here is a resource on how to do that
the source
I had a similar issue of loading my static files and here are the commands i used to change.
sudo rsync -av /home/ubuntu/MyBlog/firstproject/static /var/www/
Where MyBlog/firstproject is the directory to my project. Remember to only change the static directory.
sudo nano /etc/nginx/sites-enabled/myproject
myproject is the directory created for ngnix.
add the following lines
server {
root /var/www/static;
. . .
}
And now restart the ngnix as suggested from source. Hope this works.
- [Django]-Django-pyodbc SQL Server/freetds server connection problems on linux
- [Django]-NoReverseMatch: with arguments '()' and keyword arguments
- [Django]-How to use FilePond in Django project
- [Django]-Show management commands in admin site