How to configure Apache to deploy a project with Django and React?

23 Views Asked by At

After testing on localhost and checking that the application works, I want to deploy it from Apache (xampp). I am using Windows Server 2016 operating system, Python 3.11.8. I have also downloaded the file mod_wsgi-4.9.2-cp311-cp311-win_amd64.whl

I have tried to modify the Apache configuration (httpd.conf), adding a virtualhost (80) for the frontend and it worked correctly. The problem occurs when I want to add another virtual host (8000) for Django, causing Apache to fail to start:

<VirtualHost *:80>
    ServerName fichaje.local
    DocumentRoot "C:/Users/Administrador/Documents/fichaje/frontend/build"
    <Directory "C:/Users/Administrador/Documents/fichaje/frontend/build">
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

LoadFile "C:/Users/Administrador/AppData/Local/Programs/Python/Python311/python311.dll"
WSGIPythonHome "C:/Users/Administrador/AppData/Local/Programs/Python/Python311"
LoadModule wsgi_module "C:/Users/Administrador/AppData/Local/Programs/Python/Python311/Lib/site-packages/mod_wsgi/server/mod_wsgi.cp311-win_amd64.pyd"

<VirtualHost *:8000>
    ServerName fichaje_back.local
    Alias /static "C:/Users/Administrador/Documents/fichaje/static"
    <Directory "C:/Users/Administrador/Documents/fichaje/static">
        Require all granted
    </Directory>

    <Directory "C:/Users/Administrador/Documents/fichaje/fichaje">
        <Files wsgi.py>
            Require all granted
        </Files>
    </Directory>

    # Script WSGI
    WSGIDaemonProcess fichaje python-path=C:/Users/Administrador/Documents/fichaje;C:/Users/Administrador/Documents/fichaje/myenv/Lib/site-packages

    <IfModule mod_wsgi.c>
        WSGIPythonHome "C:/Users/Administrador/AppData/Local/Programs/Python/Python311"
    </IfModule>
</VirtualHost>
0

There are 0 best solutions below