0

我正在尝试在服务器上部署django应用程序。Linuxmod_wsgi

以下是我在 httpd.conf 文件中对 apache 的设置 -

<VirtualHost 127.0.0.1:8080>
AddDefaultCharset utf-8
LogLevel warn
ServerName myappletrade.com
#WSGIProcessGroup appletrade
WSGIScriptAlias / /var/www/html/appletrade/django.wsgi
DocumentRoot /var/www/html/appletrade
#WSGIDaemonProcess frontend user=vasim group=www
ServerAlias myappletrade.com 
CustomLog /var/www/html/appletrade/access_log   combined
ErrorLog /var/www/html/appletrade/error_log
<Directory /var/www/html/appletrade>
     Order allow,deny
     Allow from all
</Directory>
</VirtualHost>

django.wsgi 文件设置 -

import os
import sys

sys.path.insert(0, "appletrade")
sys.path.insert(0, "/var/www/html/appletrade/noneapp/env/lib/python2.6/site-packages" )

os.environ['DJANGO_SETTINGS_MODULE'] = 'noneapp.settings.development'

import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

在文件夹里面noneapp我有开发,生产服务器的设置文件。

当我尝试在浏览器中访问 myappletrade.com 时,没有任何反应。它显示 500 内部服务器错误。

我检查了错误日志。它在哪里说-

[Sat Mar 30 18:07:55 2013] [error] [client 127.0.0.1] mod_wsgi (pid=2828): Exception occurred processing WSGI script '/var/www/html/appletrade/django.wsgi'.
[Sat Mar 30 18:07:55 2013] [error] [client 127.0.0.1] Traceback (most recent call last):
[Sat Mar 30 18:07:55 2013] [error] [client 127.0.0.1]   File "/usr/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 241, in __call__
[Sat Mar 30 18:07:55 2013] [error] [client 127.0.0.1]     response = self.get_response(request)
[Sat Mar 30 18:07:55 2013] [error] [client 127.0.0.1]   File "/usr/lib/python2.7/site-packages/django/core/handlers/base.py", line 179, in get_response
[Sat Mar 30 18:07:55 2013] [error] [client 127.0.0.1]     response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
[Sat Mar 30 18:07:55 2013] [error] [client 127.0.0.1]   File "/usr/lib/python2.7/site-packages/django/core/handlers/base.py", line 224, in handle_uncaught_exception
[Sat Mar 30 18:07:55 2013] [error] [client 127.0.0.1]     if resolver.urlconf_module is None:
[Sat Mar 30 18:07:55 2013] [error] [client 127.0.0.1]   File "/usr/lib/python2.7/site-packages/django/core/urlresolvers.py", line 323, in urlconf_module
[Sat Mar 30 18:07:55 2013] [error] [client 127.0.0.1]     self._urlconf_module = import_module(self.urlconf_name)
[Sat Mar 30 18:07:55 2013] [error] [client 127.0.0.1]   File "/usr/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module
[Sat Mar 30 18:07:55 2013] [error] [client 127.0.0.1]     __import__(name)
[Sat Mar 30 18:07:55 2013] [error] [client 127.0.0.1]   File "/var/www/html/appletrade/noneapp/urls/production.py", line 4, in <module>
[Sat Mar 30 18:07:55 2013] [error] [client 127.0.0.1]     from noneapp.urls.default import urlpatterns as default_urlpatterns
[Sat Mar 30 18:07:55 2013] [error] [client 127.0.0.1]   File "/var/www/html/appletrade/noneapp/urls/default.py", line 6, in <module>
[Sat Mar 30 18:07:55 2013] [error] [client 127.0.0.1]     url(r'^catalog/', include('appletrade.urls', namespace = "catalog")),
[Sat Mar 30 18:07:55 2013] [error] [client 127.0.0.1]   File "/usr/lib/python2.7/site-packages/django/conf/urls/__init__.py", line 24, in include
[Sat Mar 30 18:07:55 2013] [error] [client 127.0.0.1]     urlconf_module = import_module(urlconf_module)
[Sat Mar 30 18:07:55 2013] [error] [client 127.0.0.1]   File "/usr/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module
[Sat Mar 30 18:07:55 2013] [error] [client 127.0.0.1]     __import__(name)
[Sat Mar 30 18:07:55 2013] [error] [client 127.0.0.1] ImportError: No module named urls

请检查我的配置设置,如果我遗漏了什么,请告诉我。

提前致谢

4

1 回答 1

0

您正试图强制 Python 2.7 使用 Python 2.6 库。您的 django.wsgi 列出了路径中的 python2.6 站点包,但错误都列出了 python2.7。

您是否也在使用 virtualenv 环境?确保您使用的是安装在该虚拟环境中的 python,而不是系统版本 - 您将丢失您拥有的任何 pip 安装包。

经过进一步审查 - 您也没有在 VirtualHost 配置中为 mod_wsgi 定义所有变量。

于 2013-04-05T18:01:55.753 回答