首页 > 解决方案 > 在 apache 和 daphne 上托管 django 频道

问题描述

我正在尝试以相同的方式在 apache 上部署 django 聊天应用程序。有人可以帮我设置 daphne 服务器吗?我对部署 django 频道完全陌生。我有一个 linux 虚拟机(ubuntu)。该站点正在运行,但未建立 websocket 连接。我在控制台中看到的错误是:

(index):16 WebSocket connection to 'ws://chat.bagdigital.in/ws/chat/lobby/' failed: 
(anonymous) @ (index):16
(index):30 Chat socket closed unexpectedly
chatSocket.onclose @ (index):30

这是我的 apache conf 文件。

<VirtualHost *:80>
    ServerName chat.bagdigital.in

    #ServerAdmin webmaster@localhost
    #DocumentRoot /var/www/html


    ErrorLog ${APACHE_LOG_DIR}/error_chat_bagwebsite.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined


    Alias /static /home/pksingh/chat-app/chat-api/static
    Alias /media /home/pksingh/chat-app/chat-api/media

    <Directory /home/pksingh/chat-app/chat-api/static>
            Require all granted
    </Directory>

    <Directory /home/pksingh/chat-app/chat-api/media>
            Require all granted
    </Directory>



    <Directory /home/pksingh/chat-app/chat-api/chatapi>
            <Files wsgi.py>
                    Require all granted
            </Files>
    </Directory>

    WSGIScriptAlias / /home/pksingh/chat-app/chat-api/chatapi/wsgi.py
    WSGIDaemonProcess bag_chat_app python-path=/home/pksingh/chat-app/chat-api python-home=/home/pksingh/chat-app/chat-api/venv
    WSGIProcessGroup bag_chat_app

我已经安装了redis服务器。如果我在端口 8000 上正常运行 django 服务器而不使用 apache,则套接字连接运行良好。

python3 manage.py runserver 0.0.0.0:8000 &

有人可以帮我在这里设置 daphne 服务器吗?

标签: djangoapacheredisdjango-channelsdaphne

解决方案


推荐阅读