#Can't get django working with apache/mod_wsgi

4 messages · Page 1 of 1 (latest)

hard beacon
#

I'm trying to get apache connected to my django project on windows. I'm very new to all this and just experimenting as I wanted to build my own website, but anyway. I've followed various guides and tried their recommendations but can't get it to work. I know my django project works because when I run it using python manage.py runserver and go to http://127.0.0.1:8000/time(the url I expect to show it on) it displays what I want to. However, on Apache, localhost.time displays a page not found page(just localhost shows It works! so the apache server is running). My wsgi file: ```import os
import sys
import site
from django.core.wsgi import get_wsgi_application

add python site packages, you can use virtualenvs also

site.addsitedir("C:\Users\VanOs\Envs\dialectensite\Lib\site-packages")

Add the app's directory to the PYTHONPATH

sys.path.append('C:\Users\VanOs\developer\django\dialecten\dialecten')
sys.path.append('C:\Users\VanOs\developer\django\dialecten\dialecten\dialecten')

os.environ['DJANGO_SETTINGS_MODULE'] = 'dialecten.settings'
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "dialecten.settings")

application = get_wsgi_application()```

My httpd.conf file has this at the end: LoadFile "C:/Program Files/Python312/python312.dll" LoadModule wsgi_module "C:/Program Files/Python312/Lib/site-packages/mod_wsgi/server/mod_wsgi.cp312-win_amd64.pyd" WSGIPythonHome "C:/Program Files/Python312"

and my httpd-vhosts.conf file has this:

#
<VirtualHost *:80>
    ServerName localhost 
    WSGIPassAuthorization On
    ErrorLog "logs/dialecten.error.log"
    CustomLog "logs/dialecten.access.log" combined
    WSGIScriptAlias /  "C:\Users\VanOs\developer\django\dialecten\dialecten\wsgi.py"
    <Directory "C:\Users\VanOs\developer\django\dialecten\dialecten">
        <Files wsgi.py>
            Require all granted
        </Files>
    </Directory>

    Alias /static "C:\Users\VanOs\developer\django\dialecten\static"
    <Directory "C:\Users\VanOs\developer\django\dialecten\static">
        Require all granted
    </Directory>  
</VirtualHost>
# end virtual SupervisionTool```
#

I also have ALLOWED_HOSTS = ['localhost',' MYIP.YESIADDEDTHIS'] in my settings.py file