[Errno 13] Permission denied: '.cache' - where is the directory I need to change permission

2,704 views
Skip to first unread message

Frank He

unread,
Aug 2, 2013, 9:05:25 PM8/2/13
to mod...@googlegroups.com
I am now deploying my django project using apache mod_wsgi, after a lot effort, it is near the end. But now when I run my project directly, I am stuck with a permission issue, and got this error:

OSError at /

[Errno 13] Permission denied: '.cache'
Request Method: GET
Request URL: http://10.3.94.239/
Django Version: 1.4
Exception Type: OSError
Exception Value:
[Errno 13] Permission denied: '.cache'
Exception Location: /usr/lib/python2.6/os.py in makedirs, line 157
Python Executable: /usr/bin/python

I believe this is because the cache can not be written, so natually,  I need to change its permission. But WHERE?

I don't know how to find out the directory.

Can you tell me anything about this?

Thanks very much in advance.

Jason Garber

unread,
Aug 2, 2013, 9:51:46 PM8/2/13
to mod...@googlegroups.com
Sounds like you need a traceback to see what it was trying to do.  Check this:


Also, assuming you are in daemon mode, the wsgi python process will inherit the apache user/group unless overridden with the arguments `user` and `group` to your WSGIProcessGroup directive in the apache configuration.

You have a couple of options:

1. make this file/dir writable by `apache` (or your webserver user)
2. see if you can move it to /tmp via django config  (best?)
3. add user and group parameters to WSGIProcessGroup so that it runs as the user that owns your files (potential security issues like writing executable code)

Not really a mod_wsgi problem, by the way, but I hope this helps point you to an answer.

J






--
You received this message because you are subscribed to the Google Groups "modwsgi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to modwsgi+u...@googlegroups.com.
To post to this group, send email to mod...@googlegroups.com.
Visit this group at http://groups.google.com/group/modwsgi.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Graham Dumpleton

unread,
Aug 2, 2013, 10:53:46 PM8/2/13
to mod...@googlegroups.com, mod...@googlegroups.com
Mostly it looks like a relative pathname is being used rather than absolute. Thus is trying to right to / as that is what working directory usually is. So permissions is an issue, but using an absolute path to a specific directory would be the first thing to solve.

Graham

Frank He

unread,
Aug 3, 2013, 2:01:59 AM8/3/13
to mod...@googlegroups.com
Thanks.

I ever released PHP/Symfony project and it has same issue, the cache directory much be changed to have ownership of user apache and be writable. I believe for python/django, this is the same.
But when I use manage.py runserver, nothing happened, only in mod_wsgi, I got this issue. I guess, in mod_wsgi, the user should be apache also, while in "manage.py runserver" ,user is root, it can write to whereever.
Sorry, I am not a IT guy, so maybe these questions are pretty silly.

1. In apache mod_wsgi, who is the user, is that 'apache'? but when I tried to use chown -R apache:apache for the whole document root, I got 'user/group does not exist', so it may be someone else;
2. I tried to print out the name at '/usr/lib/python2.6/os.py in makedirs, line 157', the name parameter is only '.cache', this is kind of confusion, where is the directory going to be created?
3. I am not using daemon mode yet, if I change to daemon mode, will that solve the problem?

For your answer, point 1 and 2, how do I control the directory position, how can I move to /tmp?

Thanks for your kind help in advance.

Frank

Frank He

unread,
Aug 3, 2013, 2:05:17 AM8/3/13
to mod...@googlegroups.com
Seemed like this is configuration of cache directory, are there any setting that can change cache directory in django setting?

Graham Dumpleton

unread,
Aug 3, 2013, 7:28:05 AM8/3/13
to mod...@googlegroups.com
Since we know nothing about your specific Django application, it is hard to guide you. All we can do is point you at the Django documentation and for you to work out what you need to change. If for example you are using a file system based cache and specified a relative directive rather than an absolute path, the documentation at:


may or may not be useful.

At this point you may be better asking on django-users list given it appears to be more of a Django configuration issue.

Graham
Reply all
Reply to author
Forward
0 new messages