开发者

apache virtual host to work with django

开发者 https://www.devze.com 2022-12-24 22:22 出处:网络
My project is under: /home/projects/testing and I\'m adding this to the buttom of my /etc/httpd/conf/httpd.conf file on Centos machine, but that is not working,

My project is under: /home/projects/testing and I'm adding this to the buttom of my /etc/httpd/conf/httpd.conf file on Centos machine, but that is not working,

<Location "/testing/">
    SetHandler python-program
    PythonHandler django.core.handlers.modpython
    SetEnv DJANGO_SETTINGS_MODULE testing.settings
    PythonOption django.root /testing
    PythonDebug On
    PythonPath "['/home/projects/'] + sys.path"
</Location>

but when requesting http://localhost/testing/jobs for example, I get:

Mod_python error: "PythonHandler django.core.handlers.modpython"

Traceback (most recent call last):

  File "/usr/lib/python2.4/site-packages/mod_python/apache.py", line 299, in HandlerDispatch
    result = object(req)

.............

 File "/usr/lib/python2.4/site-packages/Django-1.1.1-py2.4.egg/django/conf/__init__.py", line 75, in __init__
    raise ImportError, "Could not import settings '%s' (Is it on sys.path? Does it have syntax errors?): %s" % (self.SETTINGS_MODULE, e)

ImportError开发者_开发问答: Could not import settings 'testing.settings' (Is it on sys.path? Does it have syntax errors?): No module named testing.settings


You want both, the projects folder and the testing folder in your PythonPath, because your project uses paths without the "testing" in it:

PythonPath "['/home/projects/', '/home/projects/testing/'] + sys.path"


The path looks okay to me, I've just double checked that items in sys.path work with trailing slashes.

I'd suggest that this is a file permissions issue:

  • Does the user apache is running under have access to the project files?
  • Is selinux preventing access?
0

精彩评论

暂无评论...
验证码 换一张
取 消