Загрузчик Django Webpack Apache2

У меня есть проект с webpackloader djangorest-react js, все работает нормально в производстве, но мне нужно каждый раз запускать сервер django... Моя цель - запустить django и мой проект реакции с apache2 с помощью mod_wsgi, я могу запустить проект django, но реагировать оставаться недоступным...

Вот рабочая конфигурация apache2 для django, которая отлично работает.

        # The ServerName directive sets the request scheme, hostname and port that
        # the server uses to identify itself. This is used when creating
        # redirection URLs. In the context of virtual hosts, the ServerName
        # specifies what hostname must appear in the request's Host: header to
        # match this virtual host. For the default virtual host (this file) this
        # value is not decisive as it is used as a last resort host regardless.
        # However, you must set it for any further virtual host explicitly.
        #ServerName www.example.com

        ServerAdmin support@flexiwork.fr
        DocumentRoot /var/www/html
        ServerName www.flexiwork.fr
        # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
        # error, crit, alert, emerg.
        # It is also possible to configure the loglevel for particular
        # modules, e.g.
        #LogLevel info ssl:warn

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
        # For most configuration files from conf-available/, which are
        # enabled or disabled at a global level, it is possible to
        # include a line for only one particular virtual host. For example the
        # following line enables the CGI configuration for this host only
        # after it has been globally disabled with "a2disconf".
        #Include conf-available/serve-cgi-bin.conf
        Alias /static /home/olivier/coworking/API/static
        <Directory /home/olivier/coworking/API/static>
         Require all granted
        </Directory>
        Alias /media /home/olivier/coworking/API/backend/media
        <Directory /home/olivier/coworking/API/backend/media>
         Require all granted
        </Directory>
        <Directory /home/olivier/coworking/API>
                <Files wsgi.py>
                  Require all granted
                </Files>
        </Directory>
        #LogLevel info
        #WSGIApplicationGroup %{GLOBAL}
        WSGIScriptAlias / /home/olivier/coworking/API/backend/wsgi.py process-group=coworking
        WSGIDaemonProcess coworking python-path=/home/olivier/coworking/API python-home=/home/olivier/coworking/API/env processes=5 threads=15
        WSGIProcessGroup coworking
</VirtualHost>

Я думаю, что мне нужно использовать другой демон или прокси, но я немного потерялся, если у вас есть какие-либо ссылки или советы заранее.

1 ответ

Решение

Я загружал неправильный файл настроек в wsgi choices в django после сборки, это не было проблемой apache2, вот мой файл конфигурации:

import os
from django.conf import settings
from django.core.wsgi import get_wsgi_application
#from ws4redis.uwsgi_runserver import uWSGIWebsocketServer

#Here use your production settings configuration
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'backend.production_settings')

application = get_wsgi_application()

_django_app = get_wsgi_application()
#_websocket_app = uWSGIWebsocketServer()

def application(environ, start_response):
    if environ.get('PATH_INFO').startswith(settings.WEBSOCKET_URL):
        return _websocket_app(environ, start_response)
    return _django_app(environ, start_response)

И не забудьте также собрать статику

python3 manage.py collectstatic
Другие вопросы по тегам