python setting at httpd.conf:
<Directory "C:/depot/projects/web/">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
AddHandler python-program .py
PythonHandler mod_python.publisher
PythonPath "['C:/Python25/Lib/site-packages/mod_python/',]+sys.path"
PythonDebug On
</Directory>
django setting at vhosts.conf:
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host2.li
DocumentRoot "C:/depot/projects/web/"
ServerName web
ServerAlias *.web
ErrorLog "logs/dummy-host2.li-error_log"
CustomLog "logs/dummy-host2.li-access_log" common
<Location "/web">
SetHandler python-program
PythonHandler django.core.handlers.modpython
PythonOption django.root "C:/depot/projects/web/"
SetEnv DJANGO_SETTINGS_MODULE web.settings
PythonPath "['C:/depot/projects/web/'] + sys.path"
PythonDebug On
</Location>
<Location "/media">
SetHandler None
</Location>
<LocationMatch "\.(jpg|gif|png|css|js)$">
SetHandler None
</LocationMatch>
</VirtualHost>
and i always got an error :
ImportError: Settings cannot be imported, because environment variable DJANGO_SETTINGS_MODULE is undefined
Any help will be much appreciated!
From stackoverflow
-
What Version of Apache do you have and is the mod_env module enabled?
-
I am using apache 2.2 , mod_python 3.3 , django 1.0.2. python script running fine on my settings.
How to enable mod_env module?
Thanks
-
I think the issue is your PythonPath setting.
You want to append the parent directory onto sys.path
PythonPath "['C:/depot/projects/'] + sys.path"
Then when mod_python is looking for the settings.py file it will look in depot/projects/ find the web directory and in there find the settings.py file.
xlione : Thanks, changed to PythonPath "['C:/depot/projects/'] + sys.path" still no luckbskinner : The 'c:/depot/projects' setting was correct, yes? At that point you were simply missing the SetHandler None directives for the media directories and filetypes. -
Thanks all!
I got it sorted out
<VirtualHost *:80> ServerAdmin webmaster@dummy-host2.li DocumentRoot "C:/depot/projects/web/" ServerName web ServerAlias *.web ErrorLog "logs/dummy-host2.li-error_log" CustomLog "logs/dummy-host2.li-access_log" common <Location "/"> SetHandler python-program PythonHandler django.core.handlers.modpython PythonOption django.root /web SetEnv DJANGO_SETTINGS_MODULE web.settings PythonPath "['C:/depot/projects'] + sys.path" PythonDebug On </Location> <Location "/media"> SetHandler None </Location> <LocationMatch "\.(jpg|gif|png|css|js)$"> SetHandler None </LocationMatch> </VirtualHost>
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.