首先感谢大佬做的平台 @debugtalk @yinquanwang 地址:https://github.com/HttpRunner/HttpRunnerManager
下面开始我们的步骤:

0、前置

git clone 项目后,参考 readme,保证项目可以调试运行
在 settings.py 中,#29 改为 False;放掉注释行 #123 “STATIC_ROOT............”;注释掉 #130-132;
收集静态文件python manage.py collectstatic

1、安装 nginx 和 uwsgi

nginx

sudo apt-get install nginx(我的系统是 Ubuntu/Debian)

uwsgi

pip install uwsgi

2、配置 nginx.conf 和 uwsgi

nginx 配置
cd /etc/nginx/sites-available
sudo vim httprunner_nginx.conf
cd ../sites-enabled
sudo rm default
sudo ln -s ../sites-available/httprunner_nginx.conf httprunner

httprunner_nginx.conf
# mysite_nginx.conf

# the upstream component nginx needs to connect to
upstream django {
    server unix:///home/chen/PycharmProjects/HttpRunnerManager/HttpRunnerManager.sock; # for a file socket
    #server 127.0.0.1:8001; # for a web port socket (we'll use this first)
}

# configuration of the server
server {
    # the port your site will be served on
    listen      80;
    # the domain name it will serve for
    server_name example.com; # substitute your machine's IP address or FQDN
    charset     utf-8;

    # max upload size
    client_max_body_size 75M;   # adjust to taste

    # Django media
    location /static {
        alias /home/chen/PycharmProjects/HttpRunnerManager/static; # your Django project's static files - amend as required
    }

    # Finally, send all non-media requests to the Django server.
    location / {
        uwsgi_pass  django;
        include    uwsgi_params; # the uwsgi_params file you installed
    }
}

uwsgi 配置

项目目录有默认的 uwsgi.ini 文件,更改为自己配置即可,我的如下

uwsgi.ini
# myweb_uwsgi.ini file
[uwsgi]

# Django-related settings

project = HttpRunnerManager
base = /home/chen/PycharmProjects

chdir = %(base)/%(project)
module = %(project).wsgi


master = true
processes = 4


socket = %(base)/%(project)/%(project).sock
chmod-socket = 666
vacuum = true

3、启动 nginx 和 uwsgi

重启 nginx

sudo /etc/init.d/nginx restart

启动 uwsgi

uwsgi --ini /home/chen/PycharmProjects/HttpRunnerManager/uwsgi.ini

4、开启 worker,参考 readme

5、请求http://127.0.0.1/api/login/

参考文档 http://uwsgi-docs.readthedocs.io/en/latest/tutorials/Django_and_nginx.html


↙↙↙阅读原文可查看相关链接,并与作者交流