title: Target WSGI script cannot be loaded as Python module
body: <p>I am trying to deploy mod_wsgi with apache to run a django application but I am getting an error 500 internal server error The apache logs shows:</p>
  
  <pre><code>[Thu Jun 23 14:01:47 2011] [error] [client 152.78.95.64] mod_wsgi (pid=16142): Exception occurred processing WSGI script '/home/user/bms/apache/django.wsgi'.
  [Thu Jun 23 14:01:47 2011] [error] [client 152.78.95.64] Traceback (most recent call last):
  [Thu Jun 23 14:01:47 2011] [error] [client 152.78.95.64]   File "/home/user/bms/apache/django.wsgi", line 13, in &lt;module&gt;
  [Thu Jun 23 14:01:47 2011] [error] [client 152.78.95.64]     import django.core.handlers.wsgi
  [Thu Jun 23 14:01:47 2011] [error] [client 152.78.95.64] ImportError: No module named django.core.handlers.wsgi
  </code></pre>
  
  <p>My apache virtual host is as follows:</p>
  
  <pre><code>&lt;VirtualHost *:80&gt;
  
      DocumentRoot /home/user/bms
  
      &lt;Directory /home/user/bms&gt;
          Order allow,deny
          Allow from all
      &lt;/Directory&gt;
  
  WSGIDaemonProcess bms user=user group=user processes=2 threads=25 python-path=/usr/local/lib/python2.7/site-packages
  
  
      WSGIProcessGroup bms
  
      WSGIScriptAlias / /home/user/bms/apache/django.wsgi
  
  &lt;/VirtualHost&gt;
  </code></pre>
  
  <p>And the referenced wsgi file in my app directory with 0777 permissions:</p>
  
  <pre><code>import os
  import sys
  
  path = '/home/user/bms'
  if path not in sys.path:
      sys.path.append(path)
  
  os.environ['DJANGO_SETTINGS_MODULE'] = 'bms.settings'
  
  import django.core.handlers.wsgi
  application = django.core.handlers.wsgi.WSGIHandler()
  </code></pre>
  
  <p>I heard that this may be because the apache user does not have the correct permissions. However I have no idea how to fix this. I also tried starting the deamon with the www-data user and this did not solve the issue.</p>
  
  <p><strong>EDIT</strong>:</p>
  
  <p>I solved this by copying the virtual hosts file into the default one and then disabling the old one with a2dissite. I have no idea how I can do it "properly" and set it so apache goes to the virtual host I want it to though.</p>