SurfSim
SurfSim

Reputation: 1

Deploy Django (mod_python)

FIXED

my setup:

apache + mod_python VPS with CentOS django 1.2.5

I have uploaded my files to /mysite

and set httpd.conf as followed:

< VirtualHost *:80 >

    DocumentRoot /var/www/html/domain
    ServerName www.domain.com
    ServerAlias domain.com

    #django...
    <Location "/mysite">
        SetHandler python-program
        PythonHandler django.core.handlers.modpython
        SetEnv DJANGO_SETTINGS_MODULE mysite.settings
        PythonOption django.root /mysite
        PythonDebug On
        PythonPath "['/var/www/html/domain/mysite'] + sys.path"
    </Location>

    CustomLog logs/access_log cplus

< /VirtualHost >

I get this error:

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

Traceback (most recent call last):

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

  File "/usr/lib/python2.4/site-packages/django/core/handlers/modpython.py", line 228, in handler
    return ModPythonHandler()(req)

  File "/usr/lib/python2.4/site-packages/django/core/handlers/modpython.py", line 191, in __call__
    self.load_middleware()

  File "/usr/lib/python2.4/site-packages/django/core/handlers/base.py", line 33, in load_middleware
    for middleware_path in settings.MIDDLEWARE_CLASSES:

  File "/usr/lib/python2.4/site-packages/django/utils/functional.py", line 276, in __getattr__
    self._setup()

  File "/usr/lib/python2.4/site-packages/django/conf/__init__.py", line 40, in _setup
    self._wrapped = Settings(settings_module)

  File "/usr/lib/python2.4/site-packages/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 'mysite.settings' (Is it on sys.path? Does it have syntax errors?): No module named mysite.settings

Upvotes: 0

Views: 681

Answers (1)

Bernhard
Bernhard

Reputation: 8821

You are defining the handler for www.domain.com/mysite

Have you tried to access that URL?

If you want www.domain.com showing your mysite app use

<Location "/">
    ...
    # remove django.root /mysite
</Location>

EDIT

To your second problem: mysite.settings is not in your python path. Either add '/var/www/html/domain' to the PythonPath list, maybe just using settings as the DJANGO_SETTINGS_MODULE also solves the problem.

Hope that helps!

Upvotes: 1

Related Questions