Saturday, 8 October 2022

Apache + Django on Windows does not start

I am trying to set up Apache with Django on Windows but it does not seem to work.

My settings.py

ALLOWED_HOSTS = ['localhost', '127.0.0.1']

My wsgi.py


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'] = 'mrt.settings'

application = get_wsgi_application()

My httpd.conf

Listen 30080
Listen 8080


LoadFile "C:/Users/user/AppData/Local/Programs/Python/Python37/python37.dll"
LoadModule wsgi_module "c:/users/user/pycharmprojects/djangoapi/venv/lib/site-packages/mod_wsgi/server/mod_wsgi.cp37-win_amd64.pyd"
WSGIPythonHome "c:/users/user/pycharmprojects/djangoapi/venv"
WSGIPythonPath "c:/users/user/pycharmprojects/djangoapi/venv/Lib/site-packages"

My httpd-vhosts.conf


<VirtualHost *:30080>
    ServerName localhost
    WSGIPassAuthorization On
    ErrorLog "c:/users/user/pycharmprojects/djangoapi/mrt/logs/apache.error.log"
    CustomLog "c:/users/user/pycharmprojects/djangoapi/mrt/logs/apache.access.log" combined
    WSGIScriptAlias /  "c:/users/user/pycharmprojects/djangoapi/mrt/mrt/wsgi.py"
    <Directory "c:/users/user/pycharmprojects/djangoapi/mrt/mrt">
        <Files wsgi.py>
            Require all granted
        </Files>
    </Directory>

    Alias /static "c:/users/user/pycharmprojects/djangoapi/mrt/static"
    <Directory "c:/users/user/pycharmprojects/djangoapi/mrt/static">
        Require all granted
    </Directory>  
</VirtualHost>


I have tried to open http://localhost:30080/ but it says the website is not reachable. I also have tried to change Ports to *8080 but without any effect, no error appears in logs, they are empty. Without Django config Apache works. Syntax is Ok.



from Apache + Django on Windows does not start

No comments:

Post a Comment