1

我第一次尝试部署一个 django 网站。我正在使用 Django 1.5.1 我按照教程进行操作,但是在 apache 中出现错误:

[Fri Aug 02 19:48:03 2013] [error] [client 109.8.106.183] mod_wsgi (pid=10767): Exception occurred processing WSGI script '/var/www/html/portail_public/geocameroun/geocameroun/wsgi.py'.
[Fri Aug 02 19:48:03 2013] [error] [client 109.8.106.183] Traceback (most recent call last):
[Fri Aug 02 19:48:03 2013] [error] [client 109.8.106.183]   File "/usr/lib/python2.6/site-packages/django/core/handlers/wsgi.py", line 236, in __call__
[Fri Aug 02 19:48:03 2013] [error] [client 109.8.106.183]     self.load_middleware()
[Fri Aug 02 19:48:03 2013] [error] [client 109.8.106.183]   File "/usr/lib/python2.6/site-packages/django/core/handlers/base.py", line 45, in load_middleware
[Fri Aug 02 19:48:03 2013] [error] [client 109.8.106.183]     for middleware_path in settings.MIDDLEWARE_CLASSES:
[Fri Aug 02 19:48:03 2013] [error] [client 109.8.106.183]   File "/usr/lib/python2.6/site-packages/django/conf/__init__.py", line 53, in __getattr__
[Fri Aug 02 19:48:03 2013] [error] [client 109.8.106.183]     self._setup(name)
[Fri Aug 02 19:48:03 2013] [error] [client 109.8.106.183]   File "/usr/lib/python2.6/site-packages/django/conf/__init__.py", line 48, in _setup
[Fri Aug 02 19:48:03 2013] [error] [client 109.8.106.183]     self._wrapped = Settings(settings_module)
[Fri Aug 02 19:48:03 2013] [error] [client 109.8.106.183]   File "/usr/lib/python2.6/site-packages/django/conf/__init__.py", line 134, in __init__
[Fri Aug 02 19:48:03 2013] [error] [client 109.8.106.183]     raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s" % (self.SETTINGS_MODULE, e))
[Fri Aug 02 19:48:03 2013] [error] [client 109.8.106.183] ImportError: Could not import settings 'geocameroun.settings' (Is it on sys.path?): No module named settings

这个错误似乎很频繁,我有很多回复,但他们中的任何一个都解决了我的问题,或者我可能不明白什么。

我检查 geocameroun.settings 是否在 sys.path 上,所以我添加了我的 geocameroun/wsgi.py :

print "path"
print sys.path

path = '/var/www/html/portail_public/geocameroun/'
if path not in sys.path:
    sys.path.insert(0, '/var/www/html/portail_public/geocameroun/')
path = '/var/www/html/portail_public/geocameroun/geocameroun'
if path not in sys.path:
    sys.path.insert(0, '/var/www/html/portail_public/geocameroun/geocameroun')
print sys.path

在阿帕奇我得到这个:

[Fri Aug 02 19:48:03 2013] [error] ['/var/www/html/portail_public/geocameroun/geocameroun', '/usr/lib/python2.6/site-packages/MapProxy-1.5.0-py2.6.egg', '/usr/lib/python2.6/site-packages/PyYAML-3.10-py2.6-linux-x86_64.egg', '/usr/lib64/python26.zip', '/usr/lib64/python2.6', '/usr/lib64/python2.6/plat-linux2', '/usr/lib64/python2.6/lib-tk', '/usr/lib64/python2.6/lib-old', '/usr/lib64/python2.6/lib-dynload', '/usr/lib64/python2.6/site-packages', '/usr/lib64/python2.6/site-packages/PIL', '/usr/lib/python2.6/site-packages', '/usr/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg-info', '/var/www/html/portail_public/geocameroun']

所以没关系,不是吗?settings.py 在 /var/www/html/porttail_public/geocameroun/geocameroun/

在我的 wgsi.py 中,我尝试了这两行:

#os.environ.setdefault("DJANGO_SETTINGS_MODULE", "geocameroun.settings")
os.environ["DJANGO_SETTINGS_MODULE"] = "geocameroun.settings"

关于开发网络服务器,在这个文件夹 /var/www/html/porttail_public 中不起作用

/geocameroun :Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/lib/python2.6/site-packages/django/core/management/__init__.py", line 453, in execute_from_command_line
    utility.execute()
  File "/usr/lib/python2.6/site-packages/django/core/management/__init__.py", line 392, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/lib/python2.6/site-packages/django/core/management/__init__.py", line 263, in fetch_command
    app_name = get_commands()[subcommand]
  File "/usr/lib/python2.6/site-packages/django/core/management/__init__.py", line 109, in get_commands
    apps = settings.INSTALLED_APPS
  File "/usr/lib/python2.6/site-packages/django/conf/__init__.py", line 53, in __getattr__
    self._setup(name)
  File "/usr/lib/python2.6/site-packages/django/conf/__init__.py", line 48, in _setup
    self._wrapped = Settings(settings_module)
  File "/usr/lib/python2.6/site-packages/django/conf/__init__.py", line 134, in __init__
    raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s" % (self.SETTINGS_MODULE, e))
ImportError: Could not import settings 'geocameroun.settings' (Is it on sys.path?): No module named settings

但它适用于我在 /home/etienne/geocameroun 中的真实开发版本。问候

4

0 回答 0