WSGI和Django的问题

2024-05-19 10:53:00 发布

您现在位置:Python中文网/ 问答频道 /正文

请帮助理解发生了什么事。 我在Django有个项目。它在没有WSGI的情况下工作正常(我是说通过管理.py),但当我搬到WSGI时,我遇到了问题。 存在httpd错误日志:

[Mon May 02 16:58:23.316772 2016] [ssl:info] [pid 16850] [client IP:29158] AH01964: Connection to child 1 established (server server:443)
[Mon May 02 16:58:23.352418 2016] [socache_shmcb:debug] [pid 16850] mod_socache_shmcb.c(485): AH00831: socache_shmcb_store (0x81 -> subcache 1)
[Mon May 02 16:58:23.352488 2016] [socache_shmcb:debug] [pid 16850] mod_socache_shmcb.c(810): AH00847: insert happened at idx=0, data=(0:32)
[Mon May 02 16:58:23.352500 2016] [socache_shmcb:debug] [pid 16850] mod_socache_shmcb.c(815): AH00848: finished insert, subcache: idx_pos/idx_used=0/1, data_pos/data_used=0/180
[Mon May 02 16:58:23.352542 2016] [socache_shmcb:debug] [pid 16850] mod_socache_shmcb.c(506): AH00834: leaving socache_shmcb_store successfully
[Mon May 02 16:58:23.352600 2016] [ssl:debug] [pid 16850] ssl_engine_kernel.c(1812): [client IP:29158] AH02041: Protocol: TLSv1, Cipher: RC4-SHA (128/128 bits)
[Mon May 02 16:58:23.370771 2016] [ssl:debug] [pid 16850] ssl_engine_kernel.c(224): [client IP:29158] AH02034: Initial (No.1) HTTPS request received for child 1 (server server:443)
[Mon May 02 16:58:23.371004 2016] [authz_core:debug] [pid 16850] mod_authz_core.c(809): [client IP:29158] AH01626: authorization result of Require all granted: granted
[Mon May 02 16:58:23.371015 2016] [authz_core:debug] [pid 16850] mod_authz_core.c(809): [client IP:29158] AH01626: authorization result of <RequireAny>: granted
[Mon May 02 16:58:23.371202 2016] [authz_core:debug] [pid 16850] mod_authz_core.c(809): [client IP:29158] AH01626: authorization result of Require all granted: granted
[Mon May 02 16:58:23.371211 2016] [authz_core:debug] [pid 16850] mod_authz_core.c(809): [client IP:29158] AH01626: authorization result of <RequireAny>: granted
[Mon May 02 16:58:23.371650 2016] [:info] [pid 16839] [remote IP] mod_wsgi (pid=16839, process='project', application=''): Loading WSGI script '/usr/local/env/project/apache/project.wsgi'.
[Mon May 02 16:58:23.849532 2016] [:error] [pid 16839] [remote IP] mod_wsgi (pid=16839): Target WSGI script '/usr/local/env/project/apache/project.wsgi' cannot be loaded as Python module.
[Mon May 02 16:58:23.849596 2016] [:error] [pid 16839] [remote IP] mod_wsgi (pid=16839): Exception occurred processing WSGI script '/usr/local/env/project/apache/project.wsgi'.
[Mon May 02 16:58:23.849636 2016] [:error] [pid 16839] [remote IP] Traceback (most recent call last):
[Mon May 02 16:58:23.849671 2016] [:error] [pid 16839] [remote IP]   File "/usr/local/env/project/apache/project.wsgi", line 13, in <module>
[Mon May 02 16:58:23.849742 2016] [:error] [pid 16839] [remote IP]     application = get_wsgi_application()
[Mon May 02 16:58:23.849775 2016] [:error] [pid 16839] [remote IP]   File "/usr/local/env/project_django18/lib/python2.7/site-packages/django/core/wsgi.py", line 14, in get_wsgi_application
[Mon May 02 16:58:23.849832 2016] [:error] [pid 16839] [remote IP]     django.setup()
[Mon May 02 16:58:23.849850 2016] [:error] [pid 16839] [remote IP]   File "/usr/local/env/project_django18/lib/python2.7/site-packages/django/__init__.py", line 18, in setup
[Mon May 02 16:58:23.849900 2016] [:error] [pid 16839] [remote IP]     apps.populate(settings.INSTALLED_APPS)
[Mon May 02 16:58:23.849920 2016] [:error] [pid 16839] [remote IP]   File "/usr/local/env/project_django18/lib/python2.7/site-packages/django/apps/registry.py", line 108, in populate
[Mon May 02 16:58:23.850096 2016] [:error] [pid 16839] [remote IP]     app_config.import_models(all_models)
[Mon May 02 16:58:23.850125 2016] [:error] [pid 16839] [remote IP]   File "/usr/local/env/project_django18/lib/python2.7/site-packages/django/apps/config.py", line 198, in import_models
[Mon May 02 16:58:23.850224 2016] [:error] [pid 16839] [remote IP]     self.models_module = import_module(models_module_name)
[Mon May 02 16:58:23.850246 2016] [:error] [pid 16839] [remote IP]   File "/usr/lib64/python2.7/importlib/__init__.py", line 37, in import_module
[Mon May 02 16:58:23.850303 2016] [:error] [pid 16839] [remote IP]     __import__(name)
[Mon May 02 16:58:23.850324 2016] [:error] [pid 16839] [remote IP]   File "/usr/local/env/project/config/models.py", line 10, in <module>
[Mon May 02 16:58:23.851120 2016] [:error] [pid 16839] [remote IP]     from webui.models import Change
[Mon May 02 16:58:23.851181 2016] [:error] [pid 16839] [remote IP] ImportError: No module named models
[Mon May 02 16:58:23.851589 2016] [ssl:debug] [pid 16850] ssl_engine_io.c(992): [client IP:29158] AH02001: Connection closed to child 1 with standard shutdown (server server:443)

为什么WSGI不能导入它?你知道吗

这是我的wsgi.conf文件你知道吗

#!/usr/local/env/project_django18/bin/python
import os
import sys
sys.path.append('/usr/local/env/project/')
import project

os.environ['DJANGO_SETTINGS_MODULE'] = 'project.settings'
activate_this = os.path.expanduser("/usr/local/env/project_django18/bin/activate_this.py")
execfile(activate_this, dict(__file__=activate_this))

from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

这只是Django的应用。而变革就是其中的一种模式。你知道吗

如需更多信息,请告诉我


Tags: debugipenvprojectmodwsgiremoteusr

热门问题