1
votes

I want to deploy multiple Django projects on one server. It is Windows 32 bit Xampp. mod_wsgi is 32 bit. python is 32 bit. Django is ver 1.7.3.

I have read lots of posts and tried many things but I can't get past this problem.

The following error shown in the browser also indicates some version info.

Server error!
The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there was an error in a CGI script.
Error 500
localhost Apache/2.4.4 (Win32) OpenSSL/0.9.8y PHP/5.4.19 mod_wsgi/3.5 Python/2.7.6

I can successfully deploy one django application this way. There are no errors if I only deploy one, for example c:/p2/xampp/htdocs/django/mysite

When I add the second project I get the below error and only the first project works.

I get the following error in the apache error.log.

mod_wsgi (pid=11184): Exception occurred processing WSGI script 'C:/p2/xampp/htdocs/django/apache/django161c.wsgi'.
~~~~~ some lines removed ~~~~~~
ImportError: Could not import settings 'mysite.settings' (Is it on sys.path? Is there an import error in the settings file?): No module named mysite.settings

Last two lines of My httpd.conf:

LoadModule wsgi_module modules/mod_wsgi.so
Include C:/p2/xampp/htdocs/django/apache/wsgi3.conf

My wsgi3.conf

############
listen 8986
<VirtualHost *:8986>
Alias /static/ c:/p2/xampp/htdocs/django/mysite/static/
WSGIScriptAlias / "c:/p2/xampp/htdocs/django/apache/mysite.wsgi" 
    DocumentRoot "c:/p2/xampp/htdocs/django/mysite"
    ServerName 127.0.0.1
<Directory "c:/p2/xampp/htdocs/django/apache">
    Allow from all
</Directory>
</VirtualHost>
############
listen 8985
<VirtualHost *:8985>
WSGIScriptAlias / "c:/p2/xampp/htdocs/django/apache/django161c.wsgi" 
    DocumentRoot "c:/p2/xampp/htdocs/django/django161c"
    ServerName 127.0.0.1
<Directory "c:/p2/xampp/htdocs/django/apache">
    Allow from all
</Directory>
</VirtualHost>

My mysite.wsgi:

import os, sys
sys.path.append('c:/p2/xampp/htdocs/django/mysite')
os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'
# works: https://www.pythonanywhere.com/forums/topic/1629/ # this is for changes to django 1.7 # 2015-01-23_Fri_14.13-PM
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

My django161c.wsgi

import os, sys
sys.path.append('c:/p2/xampp/htdocs/django/django161c')
os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

Can you help me?

1

1 Answers

1
votes

The solution is:

There are two 'mysite.settings' It should be 'django161c.settings' in the django161c.wsgi.

This fixed it.

Then it kept asking me to login repeatedly in each project.

I then added

SESSION_COOKIE_PATH = "/django161c"

to the settings.py so that each site did not share the same sessionid cookie.

I did the same for the 'mysite' project.

SESSION_COOKIE_PATH = "/mysite"

Also, I matched the compiler and versions of mod_wsgi

I used python 2.7.9 apache 2.4 all 32 bit and all vc9 compiler The mod_wsgi was downloaded from this post:

https://groups.google.com/forum/#!topic/modwsgi/SxedM5UKvic

I named the module mod_wsgi-442-ap24-w32-vc9-py279.so

This way I know it is mod_wsgi 4.4.2, all compiled with vc9, for apache 2.4, python 2.7.9, all win32.