felix001
felix001

Reputation: 16731

Django with VirtualEnvironments

Im trying to configure apache with wsgi with virtual environments. But apache serves my django using another version (1.3.1). The other version is my default install within my standard python setup.

PATH

/opt/django/webtools_django15/
|-- __init__.py
|-- myapp
|   |-- __init__.py
|   |-- __init__.pyc
|   |-- myapp.wsgi
|   |-- myapp_settings.py
|   |-- myapp_settings.pyc
|   |-- myapp_urls.py
|   |-- forms.py
|   |-- forms.pyc
|   |-- models.py
|   |-- tests.py
|   |-- views.py
|   |-- views.py-bak
|   `-- views.pyc
|-- manage.py
|-- modules
|   `-- dnslookup.py
|-- static
|   !! omitted !!
|-- templates
|   `-- myapp
|       |-- myapp-about.html
|       |-- myapp-base.html
|       |-- myapp-cachecheck-result.html
|       |-- myapp-glossary.html
|       |-- myapp-home.html
|       |-- myapp-input-cachecheck.html
|       |-- myapp-input-cachecheck.html-bak
|       |-- myapp-input-lookup.html
|       |-- myapp-input-lookup.html-bak
|       |-- myapp-input-report.html
|       |-- myapp-input-report.html-bak
|       |-- myapp-lookup-result.html
|       |-- myapp-partners.html
|       |-- myapp-ratelimited.html
|       `-- myapp-report-result.html
`-- webtools_django15
    |-- __init__.py
    |-- __init__.pyc
    |-- settings.py
    |-- settings.py-bak
    |-- settings.pyc
    `-- urls.py

WSGI FILE

(django15)[root@bob-x django]# cat /opt/django/webtools_django15/myapp/myapp.wsgi
import os
import sys
import site

site.addsitedir("/opt/django/virtenv/django15/lib/python2.7/site-packages/")

from django.core.handlers.wsgi import WSGIHandler
sys.path.append('/opt/django/webtools_django15/')
sys.path.append('/opt/django/')

os.environ['DJANGO_SETTINGS_MODULE'] = 'myapp.myapp_settings'
application = WSGIHandler()

APACHE

<VirtualHost *:80 >
  DocumentRoot /opt/django/webtools_django15/
  ServerName myapp.co.uk
  ServerAlias www.myapp.co.uk direct.myapp.co.uk

  WSGIApplicationGroup myapp
  WSGIScriptAlias / /opt/django/webtools_django15/myapp/myapp.wsgi
  WSGIDaemonProcess myapp processes=5 python-path=/opt/django/webtools_django15:/opt/django/virtenv/django15/lib/python2.7/site-packages/ threads=1

  Alias /static/ /opt/django/webtools_django15/static/
  ErrorLog logs/myapp-error.log
  CustomLog logs/myapp-access.log common
</VirtualHost>

Any ideas of what is happening...?

Upvotes: 1

Views: 114

Answers (1)

Graham Dumpleton
Graham Dumpleton

Reputation: 58563

You are missing a WSGIProcessGroup directive to tell mod_wsgi to run things in the daemon process you configured. Use:

WSGIProcessGroup myapp
WSGIApplicationGroup %{GLOBAL}

The latter isn't strictly needed, but can avoid issues if using third party Python C extensions that do not work in sub interpreters (secondary application groups).

Upvotes: 2

Related Questions