简体   繁体   English

Nginx,Gunicorn,Virtualenv和Django-禁止使用403

[英]Nginx, Gunicorn, Virtualenv and Django - 403 Forbidden

I am no linux expert of any kind. 我不是任何形式的linux专家。 Just setting up my own server for my Django sites. 只需为Django站点设置我自己的服务器。

To my understanding its because the user does not have the right permissions ? 据我了解,这是因为用户没有正确的权限? If so, what user ware we talking about? 如果是这样,我们在谈论什么用户软件?

Is it that the "user" does not have permission to read that directory with the app in ? 是“用户”没有权限使用其中的应用读取该目录吗?

I followed this tut: Tutorial 我遵循了这个教程教程

We are talking about the user that Gunicorn (your application server) is running under. 我们正在谈论的是运行Gunicorn(您的应用程序服务器)的用户。 To check run htop on the command line and search for the gunicorn process. 要检查在命令行上运行htop并搜索gunicorn进程。 Ideally it should run under it's own user (gunicorn:gunicorn) and you should make sure your application's project folder is suitably protected - most files need only be read-only (to gunicorn) but you also need gunicorn to be able to write to the media folder (in case of user uploads etc). 理想情况下,它应在其自己的用户(gunicorn:gunicorn)下运行,并且应确保应用程序的项目文件夹受到适当的保护-大多数文件仅需只读(对gunicorn),但您还需要gunicorn才能写入文件。媒体文件夹(如果用户上传等)。 You just need to make sure that files aren't writeable to anyone except gunicorn (ie 755) 您只需要确保文件对除gunicorn(即755)以外的任何人均不可写。

fyi : 费:

Nginx is the web server/proxy and it is configured to pass any connections that request your app (via http://myapp.com for example) onto the application server which is gunicorn. Nginx是Web服务器/代理,它被配置为将请求您的应用程序的任何连接(例如,通过http://myapp.com )传递到作为gunicorn的应用程序服务器上。 Gunicorn in turn is configured to run Django which is sitting in a nice encapsulated virtualenv. 反过来,将Gunicorn配置为运行Django,该Django位于一个不错的封装virtualenv中。

Supervisor (mentioned in the article) is a python application for starting, stopping and managing all of the above processes and is very handy. Supervisor(本文中提到)是一个用于启动,停止和管理所有上述过程的python应用程序,非常方便。

I found this article to be much more simple and straight forward. 我发现本文更加简单明了。 http://honza.ca/2011/05/deploying-django-with-nginx-and-gunicorn . http://honza.ca/2011/05/deploying-django-with-nginx-and-gunicorn Follow that strictly and you shouldn't have a problem 请严格遵守,您应该不会有任何问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM