Deploy two django projects on one Xampp Windows Apache Mod_WSGI server

1,049 views
Skip to first unread message

David Gleba

unread,
Jan 27, 2015, 4:12:59 PM1/27/15
to mod...@googlegroups.com
I posted this on Stackoverflow and then saw that this group may be the preferred place to post a question.

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

Software Versions:

mod_WSGI  - win 32bit
http://www.lfd.uci.edu/~gohlke/pythonlibs/#mod_wsgi
mod_wsgi-3.5.ap24.win32-py2.7.zip
Python  -  win 32 bit
https://www.python.org/download/releases/2.7.6/
https://www.python.org/ftp/python/2.7.6/python-2.7.6.msi
Xampp Windows
32bit ver 1.8.2


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 to wsgi3.conf I get the below error and only the first project continues to work.

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?

Joonas Lehtolahti

unread,
Jan 27, 2015, 5:06:54 PM1/27/15
to mod...@googlegroups.com
On Tue, 27 Jan 2015 23:12:59 +0200, David Gleba <dgl...@gmail.com> wrote:

> 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()
>
>
> _____________
>

A shot in the dark, but is it correct that the settings module is called
'mysite.settings' in both cases, or should the second case use
django161c.settings instead?

Graham Dumpleton

unread,
Jan 27, 2015, 9:21:04 PM1/27/15
to mod...@googlegroups.com
Also, does the order you visit the sites after Apache has started matter. If you always visit the new site first, does it still fail? If it does, then something like the wrong Django settings file could well be an issue.

If it is only failing when visiting the new site second, then disable the first site and see if the new site then works.

In other words, try and isolate it to a problem with the new site, or the interaction between the new site and the existing one.

Graham

David Gleba

unread,
Jan 28, 2015, 10:38:08 AM1/28/15
to mod...@googlegroups.com
Thank you. 
That was the problem.
I should have seen that.
I should have tried each site in turn as the one and only site configured. I didn't do that.
I'm Sorry, I am embarassed.

Thank you for being kind.

Thanks,
David

David Gleba

unread,
Jan 28, 2015, 10:38:51 AM1/28/15
to mod...@googlegroups.com
Thank you for answering and helping me. I appreciate it immensely!
Reply all
Reply to author
Forward
0 new messages