Django==2.1.7 paramiko==2.7.1 dwebsocket==0.5.12
安装uwsgi
pip install uwsgi
uwsgi.ini
[uwsgi] chdir = /home/MyBlog module = MyBlog.wsgi:application socket = 127.0.0.1:8000 master = true processes = 1 threads = 2 max-requests = 6000 chmod-socket = 666 buffer-size = 65535 logto = /var/log/MyBlog.log pidfile=/home/MyBlog/uwsgi.pid ugreen ='' http-timeout = 300 enable-threads = true stats = :3031 stats-http = true #plugins=python DJANGO_SETTINGS_MODULE=MyBlog.settings WEBSOCKET_FACTORY_CLASS="dwebsocket.backends.uwsgi.factory.uWsgiWebSocketFactory" http-websockets=true
nginx.conf
server { listen 443 ssl http2 default_server ; listen [::]:443 default_server; server_name _; ssl on; ssl_certificate /etc/nginx/cert/7046953_guanacossj.com.pem; # 路径/pem文件 ssl_certificate_key /etc/nginx/cert/7046953_guanacossj.com.key; # 路径/key文件 ssl_session_timeout 5m; ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_prefer_server_ciphers on; charset utf-8; client_max_body_size 1000M; # adjust to taste include /etc/nginx/default.d/*.conf; location /static { alias /home/MyBlog/static; # ָÏdjangoµÄtaticĿ¼ } location /static/rest_framework/ { alias /usr/local/lib/python3.6/dist-packages/rest_framework/static/rest_framework/ ;} # Finally, send all non-media requests to the Django server. location / { uwsgi_pass 127.0.0.1:8000; include uwsgi_params; # the uwsgi_params file you installed; proxy_redirect off; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; uwsgi_send_timeout 600; uwsgi_connect_timeout 600; uwsgi_read_timeout 600; } }
settings.py
INSTALLED_APPS = [ ..., 'dwebsocket', ... ] WEBSOCKET_FACTORY_CLASS = 'dwebsocket.backends.uwsgi.factory.uWsgiWebSocketFactory'
GitHub - py3study/real_time_log: django查看linux实时日志