使用uwsgi启动django项目

在 manage.py 同级目录 创建 uwsgi.ini 文件 ,内容如下:

[uwsgi]
# 对外提供 http 服务的端口
http = :18123

#the local unix socket file than commnuincate to Nginx   用于和 nginx 进行数据交互的端口
socket = 127.0.0.1:8001

# the base directory (full path)  django 程序的主目录
#chdir = /data/python_workspace/plant/cmdb_v1.1
chdir = /data/python_workspace/plant/Needforspeed/cmdb_v1.2
# Django's wsgi file
wsgi-file = AutoCmdb/wsgi.py

# maximum number of worker processes
processes = 4

#thread numbers startched in each worker process
threads = 2

#monitor uwsgi status  通过该端口可以监控 uwsgi 的负载情况
stats = 0.0.0.0:9191


# clear environment on exit
vacuum          = true

# 后台运行,并输出日志
daemonize = /var/log/uwsgi.log

  nginx vhost 中创建 django.conf 文件

# the upstream component nginx needs to connect to
upstream django {
    # server unix:///path/to/your/mysite/mysite.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 ittl.dev.aixuexi.com; # substitute your machine's IP address or FQDN
    charset     utf-8;

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


#    if ($uri ~ a){
#                rewrite ^/(.*)$ gerrit.dev.aixuexi.com/$1 permanent;
#                }


    # Django media
    location /media  {
        alias /path/to/your/mysite/media;  # your Django project's media files - amend as required
    }
    rewrite /a/.*  http://gerrit.dev.aixuexi.com$uri   permanent;


    location /static {
        alias /data/python_workspace/plant/cmdb_v1.1/web/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     /usr/local/nginx/conf/uwsgi_params; # the uwsgi_params file you installed
        uwsgi_connect_timeout 300s;
        uwsgi_read_timeout 300s;
        uwsgi_send_timeout 300s;
    }
                access_log  /data/logs/django_access.log  access;
                error_log   /data/logs/django_error.log error;

}

  安装 uwsgi 模块 /usr/local/python3/bin/pip3  install uwsgi

启动项目  /usr/local/python3/bin/uwsgi  --ini  test-uwsgi.ini

转载于:https://www.cnblogs.com/liruixin/p/10574987.html

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值