Skip to content
Advertisement

Only the first Django site to be loaded works

I recently submitted a problem to stackoverflow titled Django infinite loading after multiple requests on apache using mod_wsgi. Anyways, I have recently changed a lot of that code and now I have a new problem. The first Django website I request works, however, the second one points to the first one I loaded and gives the response DisallowedHost because obviously it is trying to access that Django application with a different domain name. I obviously want it to do that it should do so if anyone can help me that would be great. Here is all my code.


EDIT: Using Razenstein’s suggestions my websites now stall, meaning they won’t load.

EDIT #2 I get this error every time I try connect to neostorm.us.to (my first website) [Sun Apr 03 19:26:58.563023 2022] [ssl:info] [pid 17528:tid 2116] [client 10.0.0.138:59334] AH01964: Connection to child 147 established (server astinarts.uk.to:443)

EDIT #3 No luck yet, I have updated my version of XAMPP with it, Apache and the problem persists. No one seems to know why this is happening. My python version if fine (3.10.4)

Vhosts

    LoadFile "C:/Users/taber/AppData/Local/Programs/Python/Python310/python310.dll"
    LoadModule wsgi_module "C:/Users/taber/AppData/Local/Programs/Python/Python310/lib/site-packages/mod_wsgi/server/mod_wsgi.cp310-win_amd64.pyd"
    WSGIPythonHome "C:/Users/taber/AppData/Local/Programs/Python/Python310"
    ##################################################################################################
    #                                       ASTINARTS.UK.TO VIRTUAL HOST                             #
    ##################################################################################################
    <VirtualHost *:443>
        ServerName astinarts.uk.to
        SSLEngine on
        SSLCertificateFile "conf/astinarts/astinarts.uk.to-chain.pem"
        SSLCertificateKeyFile "conf/astinarts/astinarts.uk.to-key.pem"
    
    Alias /static "C:/xampp/htdocs/astinarts/static"
    <Directory "C:/xampp/htdocs/astinarts/static">
        Require all granted
    </Directory>
    Alias /media "C:/xampp/htdocs/astinarts/media"
    <Directory "C:/xampp/htdocs/astinarts/media">
        Require all granted
    </Directory>
    Alias /.well-known "C:/xampp/htdocs/astinarts/.well-known"
    <Directory "C:xampphtdocsastinarts.well-known">
        Require all granted
    </Directory>
    Alias /sitemap.xml "C:/xampp/htdocs/astinarts/sitemap.xml"
    Alias /robots.txt "C:/xampp/htdocs/astinarts/robots.txt"
    <Directory "C:/xampp/htdocs/astinarts/astinarts">
        Require all granted
    </Directory>
    WSGIScriptAlias / "C:/xampp/htdocs/astinarts/astinarts/wsgi.py"
    <Directory "C:/xampp/htdocs/astinarts/astinarts">
        <Files wsgi.py>
            Require all granted
        </Files>
    </Directory>
    </VirtualHost>
    ##################################################################################################
    #                                       NEOSTORM.US.TO VIRTUAL HOST                              #
    ##################################################################################################
    <VirtualHost *:443>
        ServerName neostorm.us.to
        SSLEngine on
        SSLCertificateFile "conf/ssl.crt/neostorm.us.to-chain.pem"
        SSLCertificateKeyFile "conf/ssl.key/neostorm.us.to-key.pem"
    Alias /static "C:/xampp/htdocs/neostorm/static"
    <Directory "C:/xampp/htdocs/neostorm/static">
        Require all granted
    </Directory>
    Alias /media "C:/xampp/htdocs/neostorm/media"
    <Directory "C:/xampp/htdocs/neostorm/media">
        Require all granted
    </Directory>
    Alias /sitemap.xml "C:/xampp/htdocs/neostorm/sitemap.xml"
    Alias /robots.txt "C:/xampp/htdocs/neostorm/robots.txt"
    WSGIScriptAlias / "C:/xampp/htdocs/neostorm/neostorm/wsgi_windows.py"
    <Directory "C:/xampp/htdocs/neostorm/neostorm">
        <Files wsgi_windows.py>
            Require all granted
        </Files>
    </Directory>
    ErrorLog "C:xamppapachelogsneostorm_error.log"
    CustomLog "C:xamppapachelogsneostorm_custom.log" common
    </VirtualHost>
    ##################################################################################################
    #                                   MAIL.NEOSTORM.US.TO VIRTUAL HOST                             #
    ##################################################################################################
    <VirtualHost *:443>
        ServerName mail.neostorm.us.to
        SSLEngine on
        SSLCertificateFile "conf/ssl.crt/neostorm.us.to-chain.pem"
        SSLCertificateKeyFile "conf/ssl.key/neostorm.us.to-key.pem"
        DocumentRoot "C:/xampp/htdocs/webmail"
        <Directory "C:/xampp/htdocs/webmail">
            Require all granted
        </Directory>
    </VirtualHost>

Site 1 WSGI file

    import os
    import sys
    from django.core.wsgi import get_wsgi_application
    from pathlib import Path
    
    # Add project directory to the sys.path
    path_home = str(Path(__file__).parents[1])
    if path_home not in sys.path:
        sys.path.append(path_home)
    
    os.environ['DJANGO_SETTINGS_MODULE'] = 'astinarts.settings'
    
    application = get_wsgi_application()

Site 2 WSGI file

    import os
    import sys
    from django.core.wsgi import get_wsgi_application
    from pathlib import Path
    
    # Add project directory to the sys.path
    path_home = str(Path(__file__).parents[1])
    if path_home not in sys.path:
        sys.path.append(path_home)
    
    os.environ['DJANGO_SETTINGS_MODULE'] = 'neostorm.settings'
    
    application = get_wsgi_application()

Advertisement

Answer

The problem isn’t having multiple websites, using mod wsgi or even using Windows. The actual problem is the database. For some reason (no idea why) the default database becomes corrupt.

The solution was for me to switch to MySQL from the default database. I’m not entirely sure why the default database becomes corrupt.

This is what you can do if you want to switch to MySQL.

Inside of your settings.py find DATABASES and make it this.

DATABASES = {
'default': {
    'ENGINE'  : 'django.db.backends.mysql', # <-- UPDATED line 
    'NAME'    : 'DATABASE_NAME',                 # <-- UPDATED line 
    'USER'    : 'USER',                     # <-- UPDATED line
    'PASSWORD': 'PASSWORD',              # <-- UPDATED line
    'HOST'    : 'localhost',                # <-- UPDATED line
    'PORT'    : '3306',
}
}

See this for more information: Django website fails to load after request

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement