Skip to content Skip to sidebar Skip to footer

Django With Apache And Wsgi Throws Importerror

I'm trying to deploy my Django app to an Apache server with no luck. I succeeded with the WSGI sample application, and tried to host an empty Django project. While it works properl

Solution 1:

It looks like you've been using an old guide for setting up apache2 / wsgi. I'd recommend using the official guide at https://code.google.com/p/modwsgi/wiki/InstallationInstructions

Anyway, your specific problem is that the wsgi application isn't picking up the python path correctly. Change you VirtualHost conf to something like this

<VirtualHost *:80>
    ServerName myapp.example.com
    ServerAlias myapp
    ServerAdmin admin@example.com

    DocumentRoot /usr/local/www/django/myapp
    WSGIDaemonProcess myapp processes=2 threads=15 display-name=%{GROUP} python-path=/usr/local/www/django/myapp:/path/to/system/python/site-packages
    WSGIProcessGroup myapp
    WSGIScriptAlias / /usr/local/www/django/myapp/wsgi.py

    <Directory /usr/local/www/django/myapp>
        <Files wsgi.py>
            Order allow,deny
            Allow from all
        </Files>
    </Directory>
</VirtualHost>

Solution 2:

Your settings file is at /usr/local/www/django/myapp/settings.py, but you've set the PythonPath to /usr/local/www/django/myapp and then set DJANGO_SETTINGS_MODULE to "myapp.settings" - that would only be suitable if settings was in myapp/myapp/settings. Drop one of those references to "myapp".

Post a Comment for "Django With Apache And Wsgi Throws Importerror"