使用 Django 自带的测试服务器时:./manage.py runserver 127.0.0.1:8000
uWSGI
安装
no internal routing support, rebuild with pcre support
==>
sudo apt-get install libpcre3 libpcre3-dev
bind(): Address already in use [core/socket.c line 769]
==>
ps -aux | grep uwsgi | awk '{print $2}' | xargs kill -9
# 关闭相关进程
配置
Nginx
安装
配置
- 创建用户组
- 进入 Nginx 配置目录:
cd /etc/nginx
==>cd sites-available
- 创建配置文件:
sudo vim site.conf
- 超链:
sudo ln -s /etc/nginx/sites-available/site.conf /etc/nginx/sites-enabled/site.conf
- 重新加载配置文件:
nginx -s reload
- 重启:
sudo service nginx restart
BUG / ERROR
uWSGI uwsgi_response_write_body_do(): Connection reset by peer
解决办法:禁用 Nginx 中的缓冲区
在 Nginx 配置文件中添加 uwsgi_max_temp_file_size 0;
或者 uwsgi_buffering off;
:
我认为从 nginx 到客户端的传输速度要慢于从 uwsgi 到 nginx 的传输速度。
而且 nginx 的缓冲区已满,因此 uwsgi 等待很多时间,然后才有空间让 nginx 接收新数据,这使 uwsgi 的写请求超时。
评论区