title: apache mod_wsgi error with django in virtualenv
body: <p>I can't seem to find a good answer to this.  Who needs to own the virtualenv when running it as a WSGIDaemon?  I assume on my OS (Ubuntu 16) www-data, but I want to be sure.  Trying some new things to get this thing working based off of the answer from this post...</p>
  
  <p><a href="https://stackoverflow.com/questions/38284814/django-apache-configuration-with-wsgidaemonprocess-not-working">django apache configuration with WSGIDaemonProcess not working</a></p>
  
  <p>Does the django project, the virtualenv folder, or both need to be owned by the apache group?  What ownerships need to be in place to serve a django project without specifying a port?  Why do I get the following?  </p>
  
  <p>The root problem:</p>
  
  <pre><code> Call to 'site.addsitedir()' failed for '(null)'
  </code></pre>
  
  <p>When I start apache, I get this error.  I've followed several different guides, including:
  <a href="http://modwsgi.readthedocs.io/en/develop/user-guides/virtual-environments.html" rel="noreferrer">http://modwsgi.readthedocs.io/en/develop/user-guides/virtual-environments.html</a>
  and
  <a href="https://docs.djangoproject.com/en/1.10/howto/deployment/wsgi/modwsgi/" rel="noreferrer">https://docs.djangoproject.com/en/1.10/howto/deployment/wsgi/modwsgi/</a>
  but have had zero success.</p>
  
  <p>My virtual environment path is <code>/usr/local/virtualenvs/servicesite</code></p>
  
  <p>My django project path is <code>/home/addohm/projects/rtservice/servicesite</code>
  <em>this is where manage.py resides</em>,
  which leaves <code>/home/addohm/projects/rtservice/servicesite/servicesite</code> as the location of my wsgi.py.</p>
  
  <p><strong>wsgi.py:</strong></p>
  
  <pre><code>SERVICESITE = ['/usr/local/virtualenvs/servicesite/lib/python3.5/site-packages']
  
  import os
  import sys
  import site
  
  prev_sys_path = list(sys.path)
  
  for directory in SERVICESITE
          site.addsitedir(directory)
  
  new_sys_path = []
  for item in list(sys.path):
          if item not in prev_sys_path:
                  new_sys_path.append(item)
                  sys.path.remove(item)
  sys.path[:0] = new_sys_path
  
  """  **Doesn't seem to work, throwing error in apache logs**
  site.addsitedir('/usr/local/virtualenvs/servicesite/lib/python3.5/site-packages')
  """
  
  from django.core.wsgi import get_wsgi_application
  os.environ.setdefault("DJANGO_SETTINGS_MODULE", "servicesite.settings")
  application = get_wsgi_application()
  DJANGO_PATH =  os.path.join(os.path.abspath(os.path.dirname(__file__)), '..')
  sys.path.append(DJANGO_PATH)
  </code></pre>
  
  <p><strong>apache2.conf</strong></p>
  
  <p>[...]</p>
  
  <pre><code>WSGIDaemonProcess servicesite python-path=/home/addohm/projects/rtservice/servicesite:/usr/local/virtualenvs/servicesite/lib/python3.5/site-packages
  WSGIProcessGroup servicesite
  WSGIScriptAlias / /home/addohm/projects/rtservice/servicesite/servicesite/wsgi.py
  
  Alias /static/ /home/addohm/projects/rtservice/servicesite/static/
  &lt;Directory /home/addohm/projects/rtservice/servicesite/static/&gt;
          Require all granted
  &lt;/Directory&gt;
  
  &lt;Directory /home/addohm/projects/rtservice/servicesite/servicesite&gt;
          &lt;Files wsgy.py&gt;
                  Require all granted
          &lt;/Files&gt;
  &lt;/Directory&gt;
  </code></pre>
  
  <p>[...]</p>