English 中文(简体)
与 Apache 虚拟主机的对接1.4 连接点为 Apache 虚拟主机 - 路径问题
原标题:django 1.4 with apache virtualhost - path problems

我试图升级我的应用程序 从对角1.2到1.4, 我已经成功地测试了 与内建的网络服务器。

然而,我很难将它作为阿帕奇(Ubuntu)的虚拟住房部署。

我的网站可用/ 默认 包含:

<VirtualHost *:80>
    ServerName myapplication

    WSGIScriptAlias / /usr/share/myapplication/wsgi.py
    WSGIDaemonProcess myapplication python-path=/usr/share/myapplication:/usr/lib/python2.6/dist-packages

    <Directory /usr/share/myapplication>
    <Files wsgi.py>
      Order deny,allow
      Allow from all
    </Files>
    </Directory>

</VirtualHost>

文件 /usr/share/myapplication/wsgi.py 包含以下标准:

import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "myapplication.settings")
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

Apache将启动 OK, 但当我去 http://myapplication 我得到500: 内部服务器错误和 apache 日志显示 :

ImportError: Could not import settings  WCReporter.settings  (Is it on sys.path?): No module named WCReporter.settings

我使用WSGIDaemon程序是否正确?

谢谢 谢谢

最佳回答

http://rc98.net/django_wsgi 中以以下方式解决了这个问题。

可用网站/ 默认 :

<VirtualHost *:80>
    ServerName myapplication

    WSGIDaemonProcess myapplication
    WSGIProcessGroup myapplication

    WSGIScriptAlias / /usr/share/myapplication/wsgi.py
    <Directory /usr/share/myapplication>
    <Files wsgi.py>
      Order deny,allow
      Allow from all
    </Files>
    </Directory>

</VirtualHost>

和 wsgi. py :

import os,sys

path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
if path not in sys.path:
    sys.path.append(path)

path =  /usr/share/myapplication 
if path not in sys.path:
    sys.path.append(path)

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "myapplication.settings")

from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
问题回答

您可以在运行时打印您的路径 :

#init.py

    import sys
    print sys.path
  1. have you got an init file in the project base dir?
  2. does it work if you import settings instead of myapp.settings?




相关问题
Using SimplePie with CodeIgniter and XAMPP

I am using CodeIgniter 1.7.2 with XAMPP 1.7.2 on a Windows computer. I am trying to make use of SimplePie. I followed all the instructions I could find: a copy of simplepie.inc is in my applications/...

Multiple Sites with common files

I have developed over 50 sites that all use the exact same files other than CSS and IMAGES, I currently duplicate the files each time I create a new site and upload different css and images. What ...

http server validation

I finish a litle http server, writing from scratch. I would like to be sure that my imlementation is conforme to the HTTP specifications. W3C give us tools for HTML/XML conformance, but i see nothing ...

热门标签