3๐
Go read:
This describes all the common reasons why you can get mixing of responses for sites when running Django under Apache/mod_wsgi.
In addition to that, you can also see issues if not careful where you have sites sharing a common parent domain. For this you may have to adjust cookie domains or names if each site was setup and is effectively sharing the same cookie.
Also be aware of sharing common backend services for all sites such as memcache as there can be contention as far as distinct sites use the same keys for data. For that setup things to use a distinct memcache key prefix to keep data separate.
0๐
First of all, combine identical sites like this:
NameVirtualHost *:80
<VirtualHost *:80>
ServerName www.siteA.tk
ServerAlias siteA.tk siteA.com www.siteA.com
WSGIScriptAlias / /home/me/siteA/siteA/wsgi.py
Alias /static/ /var/www/siteA/static/
</VirtualHost>
<VirtualHost *:80>
ServerName www.siteB.tk
ServerAlias siteB.tk siteB.com www.siteB.com
WSGIScriptAlias / /home/me/siteB/siteB/wsgi.py
</VirtualHost>
Also, instead of using WSGIPythonPath
in Apache configuration, add this line in the beginning of your wsgi.py
file (this example is for siteA, change it properly for siteB):
import sys
sys.path.append('/home/me/siteA')
- [Django]-Get all action names from ViewSet (drf)
- [Django]-How do I limit a text length and add dots to show continuation python django
- [Django]-How to set related_name in ManyToMany field in an abstract model?
- [Django]-Django subquery using QuerySet
- [Django]-Intercepting a Django 500 error for logging, without creating/serving a custom 500.html
0๐
Self realization.
The solution was to change the wsgi.py files generated by django. In fact it specifically says in the comments:
# We defer to a DJANGO_SETTINGS_MODULE already in the environment. This breaks
# if running multiple sites in the same mod_wsgi process. To fix this, use
# mod_wsgi daemon mode with each site in its own daemon process, or use
# os.environ["DJANGO_SETTINGS_MODULE"] = "siteA.settings"
I used the immediately simple option and replaced the given line below the comment with
os.environ["DJANGO_SETTINGS_MODULE"] = "yoursite.settings"
Restart apache
$ apachectl -k graceful
Problem solved.
- [Django]-Django i18n: makemessages only on site level possible?
- [Django]-Django QuerySet/Manager filter employees by age from birthday
- [Django]-How can I improve this many-to-many Django ORM query and model set?
- [Django]-Django add to many to many field working without save
- [Django]-How to find all Django foreign key references to an instance