Search code examples
djangolinuxapachewebserverwsgi

Django on Linux Apache Webserver (Chrome doesn´t load)


I am trying to install a Django Webserver on a Linux Apache2 Webserver.

I am Stuck and dont know why I am not getting any Response from the Webserver.

My Apache Conf:

WSGIPythonHome /var/venvs/djangoVenv
WSGIPythonPath /var/www/DjangoProject/

<VirtualHost *:80>
        DocumentRoot /var/www/DjangoProject

        Alias /static /var/www/DjangoProject/static

        WSGIScriptAlias / /var/www/DjangoProject/DjangoProject/wsgi.py
        WSGIProcessGroup DjangoProject
        WSGIPassAuthorization On

        <Directory /var/www/DjangoProject/DjangoProject>
                <Files wsgi.py>
                        Require all granted
                </Files>
        </Directory>

        <Directory /var/www/DjangoProject>
                Require all granted
        </Directory>

        <Directory /var/www/DjangoProject/static>
                Require all granted
        </Directory>

        ErrorLog /var/www/logs/error.log
        CustomLog /var/www/logs/custom.log combined
</VirtualHost>

And my Python wsgi File:

import os

from django.core.wsgi import get_wsgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'DjangoProject.settings')

application = get_wsgi_application()

I have running my Django Server on Port 80 but Chrome only shows me, that the Website is unreachable.

Chrome Reply

Edit: I did a few changes and my apache Conf now looks like this:

<VirtualHost *:80>
        DocumentRoot /var/www/TestProject
        ErrorLog /var/www/logs/error.log
        CustomLog /var/www/logs/custom.log combined
        Alias /static /var/www/TestProject/static
        <Directory /var/www/TestProject/static>
                Require all granted
        </Directory>
        Alias /static /var/www/TestProject/media
        <Directory /var/www/TestProject/media>
                Require all granted
        </Directory>
        <Directory /var/www/TestProject/TestProject>
                <Files wsgi.py>
                        Require all granted
                </Files>
        </Directory>
        WSGIDaemonProcess TestProject python-path=/var/www/TestProject python-home=/var/venv/djangoEnv/lib/python3.7/site-packages/
        WSGIProcessGroup TestProject
        WSGIApplicationGroup %{GLOBAL}
        WSGIScriptAlias / /var/www/TestProject/TestProject/wsgi.py
</VirtualHost>

Now when I try to load the Website Chrome is loading forever and dosen´t stop. After a while this shows up: Gateway Timeout


Solution

  • I just followed this Video Step by Step and it just Works:

    https://www.youtube.com/watch?v=Sa_kQheCnds

    I don´t know what was the Problem but now it works.