I'm relatively new to all the server technology and I followed this tutorial to deploy my django app on an Apache Webserver, using mod_wsgi:
Here is my virtual hosts file:
<VirtualHost *:80> ServerName www.abcxyz.org ServerAlias abcxyz.org WSGIScriptAlias / /var/www/abcxyz/django/abcxyz/wsgi_prod.py Alias /static/ /var/www/abcxyz/static/ <Location "/static/"> Options -Indexes </Location> </VirtualHost>
As I understand it, the
wsgi_prod.py file should only be executed once when the server starts (or when it gets the first request - I'm not particular sure about this). But in my application it is executed multiple times, when sending requests to the server.
It is not executed on all requests but on some of them. And there are also some request, that trigger the execution of
wsgi_prod.py only sometimes.
This is my wsgi_prod.py file:
import os import sys import site import thread # Add the site-packages of the chosen virtualenv to work with site.addsitedir('/etc/Envs/abcxyz/local/lib/python2.7/site-packages') # Add the app's directory to the PYTHONPATH sys.path.append('/var/www/abcxyz/django') sys.path.append('/var/www/abcxyz/django/abcxyz') os.environ['DJANGO_SETTINGS_MODULE'] = 'abcxyz.settings.production' # Activate your virtual env activate_env=os.path.expanduser("/etc/Envs/abcxyz/bin/activate_this.py") execfile(activate_env, dict(__file__=activate_env)) print "WSGI RUN!!!" import django.core.handlers.wsgi application = django.core.handlers.wsgi.WSGIHandler()
Has anyone any idea what could have went wrong in my case and where I could start searching for the error?