Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stuck with deploying django with apache + mod_wsgi

I get an 500 internal server error and in the log files it writes:

[Thu Jun 14 16:30:22 2012] [error] [client 127.0.0.1] ImportError: Could not import settings 'mysite.settings' (Is it on sys.path?): No module named mysite.settings

here is my httpd.conf:

ServerName localhost

<VirtualHost *:80>
    ServerAdmin [email protected]
    ServerName mysite.com
    ServerAlias www.mysite.com
    DocumentRoot /var/www/mysite/
    LogLevel warn
    WSGIDaemonProcess processes=2 maximum-requests=500 threads=1
    WSGIScriptAlias / /var/www/mysite/mysite/wsgi.py
    Alias /media /var/www/mysite/mysite/static/media/
</VirtualHost>

wsgi.py:

import os

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings")
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
like image 881
Tony Avatar asked Dec 26 '22 23:12

Tony


1 Answers

This problem is covered in both the mod-wsgi documentation http://code.google.com/p/modwsgi/wiki/IntegrationWithDjango and the Django deployment documentation https://docs.djangoproject.com/en/1.4/howto/deployment/wsgi/modwsgi/ which note that the project must be on your Python path. You can use the WSGIPythonPath directive or set the python-path in your WSGIDaemonProcess directive from the Django documentation. Or you can add it to the sys.path in your wsgi file as the mod-wsgi docs state.

like image 185
Mark Lavin Avatar answered Jan 05 '23 23:01

Mark Lavin