使用Django + APACHE + mod_wsgi的会话问题 [英] session issue with django+apache+mod_wsgi
问题描述
我写了一个Django应用程序,并把它放在一个CentOS的服务器上。当我使用Django开发Web服务器这肯定是好的。
I've written a django application, and put it on a CentOS server. It is definitely okay when I use django development web server.
如我所说的蟒蛇./manage.py的runserver启动它,然后从浏览器访问该服务器的另一台计算机上。我可以登入一次,并访问所有网页没有问题。
Such as I start it by "python ./manage.py runserver", and access that server from browser on another computer. I can sign in one time, and access all the pages without issues.
然而,当我使用Apache + mod_wsgi的运行它,我才发现我有时间,用户名和密码时登录。我想可能有一些问题与会话中间件,所以,我怎么能找到问题的根源并解决它?
However when I run it with apache+mod_wsgi, I just found I have to login with user and password time by time. I think maybe there is some problem with the session middleware, so, how can I find the root cause and fix it?
推荐答案
有几个不同的选择这一点。
There are a couple of different options for this.
在的情形产生(恕我直言)的顺序为:
In order of likelyhood (imho):
- 会议后端使用缓存系统来存储会话和你使用
locmem
缓存后端 - 会话后端不存储饼干(启用安全cookie?cookie的超时?不正确的日期在服务器上?)
- 会话中间件可能不会被加载(用于生产服务器的自定义设置?)
在缓存中存储会话是只有当你使用memcached作为缓存后端一个很好的解决方案。所以,如果你存储在缓存中的会话,请确保您使用的memcache:)
Storing the session in the cache is only a good solution if you use memcached as the cache backend. So if you're storing the sessions in cache, make sure you use memcache :)
无论哪种方式,检查 SESSION_ENGINE
设置为 django.contrib.sessions.backends.db
Either way, check if SESSION_ENGINE
is set to django.contrib.sessions.backends.db
这篇关于使用Django + APACHE + mod_wsgi的会话问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!