rdhl7部署django

本文介绍如何使用pip安装UWSGI并配置XML文件,同时详细展示了Nginx的安装步骤及配置方法,包括YUM源设置、启动停止命令、配置文件编辑等。

一、uwsgi安装部署

1、pip install uwsgi
2、配置xml文件

 <uwsgi>
    <socket>127.0.0.1:8001</socket>
    <chdir>/opt/dockeradmin</chdir><!-->项目路径,用来处理请求<-->
    <pythonpath>/opt/dockeradmin</pythonpath> <!-->应用文件所在的路径,也就是项目所在路径,也可写成'..'意为当前路径<-->
    <module>wsgi</module><!-->wsgi.py文件位置,如果在某个app下面则写成appname.wsgi,因为这个问题曾经报错no python application found, check your startup logs for errors,折腾死了<-->
    <processes>4</processes>
    <py-autoreload>1</py-autoreload>
    <pidfile>/tmp/dockeradmin.pid</pidfile>
</uwsgi>

3、 uwsgi -x uwsgi.xml –daemonize /var/log/uwsgi.log 运行

二、nginx

1、准备yum源
vi /etc/yum.repo.d/nginx.repo

[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/mainline/rhel/7/$basearch/
gpgcheck=0
enable=1

准备好了源之后,更新源

$ yum clean all
$ yum makecache

2、安装nginx

$ yum install -y nginx

安装成功之后可以通过 $ nginx -v查看版本

[root@docker php-5.5.38]# nginx -v
   nginx version: nginx/1.13.0

3、启动nginx

    nginx

4、关闭nginx

nginx -s stop

5、重新加载

nginx -s reload

6、nginx配置
vim /etc/nginx/conf.d/default.conf

user  nginx;
worker_processes  1;

error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    keepalive_timeout  65;

    #gzip  on;

    include /etc/nginx/conf.d/*.conf;

    upstream project1 {
        server 127.0.0.1:8001; # for a web port socket (we'll use this first)    
    }

    upstream project2 {
        server 127.0.0.1:8002; # for a web port socket (we'll use this first)
    }

    server{
        listen       8091;
        #server_name  somename  alias  another.alias;

        location / {
            include /opt/dockeradmin/uwsgi_params;
            uwsgi_pass project1;
        }

        location /static/ {
            alias  /opt/dockeradmin/static/;
        }
    } 

    server{
        listen       8092;
        #server_name  somename  alias  another.alias;

        location / {
            include /etc/nginx/uwsgi_params;
            uwsgi_pass project2;
        }   

        location /static/ {
            alias  /root/project/python-publish/pub-update/static/;
        }   
    }    
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值