错误13被拒绝:。缓存的django应用程序?

时间:2021-08-10 18:22:18

I am deploying a django app on Ubuntu Server 14.04 and I have successfully been able to get to the IP address in my browser. However, now I am getting a django debug error which is labeled "[Errno 13] Permission Denied: '.cache'" I am not really sure what this means. The path that the app is getting choke on is '/usr/lib/python3.4/os.py', which seems weird to me because I am using a virtual environment, that is not under that directory, to establish the python version, and dependencies. Any help would be really appreciated. I realize that a lot of people have had the same problem, but I haven't found a single good solution to this. I am not looking for a solution that just allows all permissions for a certain directory; I would like to maintain a good level of security when applying this fix. Thanks in advanced.

我正在Ubuntu服务器14.04上部署django应用程序,我已经成功地访问了浏览器中的IP地址。然而,现在我得到一个django调试错误,它被标记为“[Errno 13] Permission Denied: '。我不太清楚这意味着什么。应用程序被阻塞的路径是“/usr/lib/python3.4/os”。py',这在我看来很奇怪,因为我正在使用一个不在那个目录下的虚拟环境来建立python版本和依赖关系。如有任何帮助,我们将不胜感激。我意识到很多人都有同样的问题,但是我还没有找到一个好的解决方法。我不是在寻找一个解决方案,它只允许对某个目录进行所有权限;我希望在应用此修复时保持良好的安全性。由于先进。

From error.log:

从error.log:


    [Wed May 18 20:42:24.836874 2016] [:error] [pid 6078:tid 139663218018048] Traceback (most recent call last):
    [Wed May 18 20:42:24.836879 2016] [:error] [pid 6078:tid 139663218018048]   File "/home/openflow/.virtualenvs/sched_app.v0.2/lib/python3.4/site-packages/django/core/handlers/base.py", line 123, in get_response
    [Wed May 18 20:42:24.836883 2016] [:error] [pid 6078:tid 139663218018048]     response = middleware_method(request)
    [Wed May 18 20:42:24.836886 2016] [:error] [pid 6078:tid 139663218018048]   File "/home/openflow/.virtualenvs/sched_app.v0.2/lib/python3.4/site-packages/django/middleware/common.py", line 61, in process_request
    [Wed May 18 20:42:24.836890 2016] [:error] [pid 6078:tid 139663218018048]     if self.should_redirect_with_slash(request):
    [Wed May 18 20:42:24.836894 2016] [:error] [pid 6078:tid 139663218018048]   File "/home/openflow/.virtualenvs/sched_app.v0.2/lib/python3.4/site-packages/django/middleware/common.py", line 79, in should_redirect_with_slash
    [Wed May 18 20:42:24.836898 2016] [:error] [pid 6078:tid 139663218018048]     not urlresolvers.is_valid_path(request.path_info, urlconf)
    [Wed May 18 20:42:24.836901 2016] [:error] [pid 6078:tid 139663218018048]   File "/home/openflow/.virtualenvs/sched_app.v0.2/lib/python3.4/site-packages/django/core/urlresolvers.py", line 668, in is_valid_path
    [Wed May 18 20:42:24.836905 2016] [:error] [pid 6078:tid 139663218018048]     resolve(path, urlconf)
    [Wed May 18 20:42:24.836908 2016] [:error] [pid 6078:tid 139663218018048]   File "/home/openflow/.virtualenvs/sched_app.v0.2/lib/python3.4/site-packages/django/core/urlresolvers.py", line 534, in resolve
    [Wed May 18 20:42:24.836912 2016] [:error] [pid 6078:tid 139663218018048]     return get_resolver(urlconf).resolve(path)
    [Wed May 18 20:42:24.836915 2016] [:error] [pid 6078:tid 139663218018048]   File "/home/openflow/.virtualenvs/sched_app.v0.2/lib/python3.4/site-packages/django/core/urlresolvers.py", line 374, in resolve
    [Wed May 18 20:42:24.836919 2016] [:error] [pid 6078:tid 139663218018048]     for pattern in self.url_patterns:
    [Wed May 18 20:42:24.836922 2016] [:error] [pid 6078:tid 139663218018048]   File "/home/openflow/.virtualenvs/sched_app.v0.2/lib/python3.4/site-packages/django/utils/functional.py", line 33, in __get__
    [Wed May 18 20:42:24.836939 2016] [:error] [pid 6078:tid 139663218018048]     res = instance.__dict__[self.name] = self.func(instance)
    [Wed May 18 20:42:24.836944 2016] [:error] [pid 6078:tid 139663218018048]   File "/home/openflow/.virtualenvs/sched_app.v0.2/lib/python3.4/site-packages/django/core/urlresolvers.py", line 417, in url_patterns
    [Wed May 18 20:42:24.836947 2016] [:error] [pid 6078:tid 139663218018048]     patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
    [Wed May 18 20:42:24.836951 2016] [:error] [pid 6078:tid 139663218018048]   File "/home/openflow/.virtualenvs/sched_app.v0.2/lib/python3.4/site-packages/django/utils/functional.py", line 33, in __get__
    [Wed May 18 20:42:24.836954 2016] [:error] [pid 6078:tid 139663218018048]     res = instance.__dict__[self.name] = self.func(instance)
    [Wed May 18 20:42:24.836958 2016] [:error] [pid 6078:tid 139663218018048]   File "/home/openflow/.virtualenvs/sched_app.v0.2/lib/python3.4/site-packages/django/core/urlresolvers.py", line 410, in urlconf_module
    [Wed May 18 20:42:24.836962 2016] [:error] [pid 6078:tid 139663218018048]     return import_module(self.urlconf_name)
    [Wed May 18 20:42:24.836965 2016] [:error] [pid 6078:tid 139663218018048]   File "/usr/lib/python3.4/importlib/__init__.py", line 109, in import_module
    [Wed May 18 20:42:24.836968 2016] [:error] [pid 6078:tid 139663218018048]     return _bootstrap._gcd_import(name[level:], package, level)
    [Wed May 18 20:42:24.836972 2016] [:error] [pid 6078:tid 139663218018048]   File "", line 2254, in _gcd_import
    [Wed May 18 20:42:24.836975 2016] [:error] [pid 6078:tid 139663218018048]   File "", line 2237, in _find_and_load
    [Wed May 18 20:42:24.836978 2016] [:error] [pid 6078:tid 139663218018048]   File "", line 2226, in _find_and_load_unlocked
    [Wed May 18 20:42:24.836982 2016] [:error] [pid 6078:tid 139663218018048]   File "", line 1200, in _load_unlocked
    [Wed May 18 20:42:24.836985 2016] [:error] [pid 6078:tid 139663218018048]   File "", line 1129, in _exec
    [Wed May 18 20:42:24.836988 2016] [:error] [pid 6078:tid 139663218018048]   File "", line 1471, in exec_module
    [Wed May 18 20:42:24.836991 2016] [:error] [pid 6078:tid 139663218018048]   File "", line 321, in _call_with_frames_removed
    [Wed May 18 20:42:24.836995 2016] [:error] [pid 6078:tid 139663218018048]   File "var/www/html/scheduler.marist.edu/sched_app/sched_site/urls.py", line 20, in 
    [Wed May 18 20:42:24.836998 2016] [:error] [pid 6078:tid 139663218018048]     url(r'^sched_app/', include('sched_app.urls')),
    [Wed May 18 20:42:24.837002 2016] [:error] [pid 6078:tid 139663218018048]   File "/home/openflow/.virtualenvs/sched_app.v0.2/lib/python3.4/site-packages/django/conf/urls/__init__.py", line 52, in include
    [Wed May 18 20:42:24.837005 2016] [:error] [pid 6078:tid 139663218018048]     urlconf_module = import_module(urlconf_module)
    [Wed May 18 20:42:24.837009 2016] [:error] [pid 6078:tid 139663218018048]   File "/usr/lib/python3.4/importlib/__init__.py", line 109, in import_module
    [Wed May 18 20:42:24.837012 2016] [:error] [pid 6078:tid 139663218018048]     return _bootstrap._gcd_import(name[level:], package, level)
    [Wed May 18 20:42:24.837015 2016] [:error] [pid 6078:tid 139663218018048]   File "", line 2254, in _gcd_import
    [Wed May 18 20:42:24.837018 2016] [:error] [pid 6078:tid 139663218018048]   File "", line 2237, in _find_and_load
    [Wed May 18 20:42:24.837022 2016] [:error] [pid 6078:tid 139663218018048]   File "", line 2226, in _find_and_load_unlocked
    [Wed May 18 20:42:24.837025 2016] [:error] [pid 6078:tid 139663218018048]   File "", line 1200, in _load_unlocked
    [Wed May 18 20:42:24.837028 2016] [:error] [pid 6078:tid 139663218018048]   File "", line 1129, in _exec
    [Wed May 18 20:42:24.837036 2016] [:error] [pid 6078:tid 139663218018048]   File "", line 1471, in exec_module
    [Wed May 18 20:42:24.837040 2016] [:error] [pid 6078:tid 139663218018048]   File "", line 321, in _call_with_frames_removed
    [Wed May 18 20:42:24.837043 2016] [:error] [pid 6078:tid 139663218018048]   File "var/www/html/scheduler.marist.edu/sched_app/sched_app/urls.py", line 2, in 
    [Wed May 18 20:42:24.837047 2016] [:error] [pid 6078:tid 139663218018048]     from . import views
    [Wed May 18 20:42:24.837050 2016] [:error] [pid 6078:tid 139663218018048]   File "var/www/html/scheduler.marist.edu/sched_app/sched_app/views.py", line 131, in 
    [Wed May 18 20:42:24.837054 2016] [:error] [pid 6078:tid 139663218018048]     h = httplib2.Http(".cache")
    [Wed May 18 20:42:24.837057 2016] [:error] [pid 6078:tid 139663218018048]   File "/home/openflow/.virtualenvs/sched_app.v0.2/lib/python3.4/site-packages/httplib2/__init__.py", line 907, in __init__
    [Wed May 18 20:42:24.837060 2016] [:error] [pid 6078:tid 139663218018048]     self.cache = FileCache(cache)
    [Wed May 18 20:42:24.837064 2016] [:error] [pid 6078:tid 139663218018048]   File "/home/openflow/.virtualenvs/sched_app.v0.2/lib/python3.4/site-packages/httplib2/__init__.py", line 675, in __init__
    [Wed May 18 20:42:24.837067 2016] [:error] [pid 6078:tid 139663218018048]     os.makedirs(self.cache)
    [Wed May 18 20:42:24.837071 2016] [:error] [pid 6078:tid 139663218018048]   File "/usr/lib/python3.4/os.py", line 237, in makedirs
    [Wed May 18 20:42:24.837074 2016] [:error] [pid 6078:tid 139663218018048]     mkdir(name, mode)
    [Wed May 18 20:42:24.837079 2016] [:error] [pid 6078:tid 139663218018048] PermissionError: [Errno 13] Permission denied: '.cache'

1 个解决方案

#1


1  

Here's your error:

这是你的错误:

  File "var/www/html/scheduler.marist.edu/sched_app/sched_app/views.py", line 131, in 
    [Wed May 18 20:42:24.837054 2016] [:error] [pid 6078:tid 139663218018048]     h = httplib2.Http(".cache")

This has nothing to do with django caching as I (and probably almost everyone else who read this) supposed. It's to do with your use of httplib2.

这与django缓存没有任何关系,正如我(可能还有几乎所有阅读本文的人)所认为的那样。这和你使用httplib2有关。

Comment out that section of code and you will be able to start up.

注释掉这段代码,您就可以开始了。

Update. I am not an expert on httplib2 but what I just read is that ".cache" implies the directory where httplib2 will cache pages that it will retrieve. If you don't pass that parameter it will not cache anything. You might want to use a safe but writable path here if you want to enable caching.

更新。我不是httplib2的专家,但我刚才读到的是。缓存“暗示了httplib2将缓存它将要检索的页面的目录。如果不传递该参数,它将不会缓存任何内容。如果希望启用缓存,您可能需要在这里使用安全但可写的路径。

#1


1  

Here's your error:

这是你的错误:

  File "var/www/html/scheduler.marist.edu/sched_app/sched_app/views.py", line 131, in 
    [Wed May 18 20:42:24.837054 2016] [:error] [pid 6078:tid 139663218018048]     h = httplib2.Http(".cache")

This has nothing to do with django caching as I (and probably almost everyone else who read this) supposed. It's to do with your use of httplib2.

这与django缓存没有任何关系,正如我(可能还有几乎所有阅读本文的人)所认为的那样。这和你使用httplib2有关。

Comment out that section of code and you will be able to start up.

注释掉这段代码,您就可以开始了。

Update. I am not an expert on httplib2 but what I just read is that ".cache" implies the directory where httplib2 will cache pages that it will retrieve. If you don't pass that parameter it will not cache anything. You might want to use a safe but writable path here if you want to enable caching.

更新。我不是httplib2的专家,但我刚才读到的是。缓存“暗示了httplib2将缓存它将要检索的页面的目录。如果不传递该参数,它将不会缓存任何内容。如果希望启用缓存,您可能需要在这里使用安全但可写的路径。