zoukankan      html  css  js  c++  java
  • Django 部署

     mysql

    收集静态文件

     

    nginx配置

    # For more information on configuration, see:
    #   * Official English Documentation: http://nginx.org/en/docs/
    #   * Official Russian Documentation: http://nginx.org/ru/docs/
    
    user root;
    worker_processes 4;
    
    error_log /var/log/nginx/error.log;
    pid /var/run/nginx.pid;
    
    events {
        worker_connections  1024;
    }
    
    
    http {
        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;
        tcp_nodelay         on;
        keepalive_timeout   65;
        #types_hash_max_size 2048;
    
        include             /etc/nginx/mime.types;
        default_type        application/octet-stream;
        
        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)
        }
        server {
            listen      80;
    
            #server_name ; 
            charset     utf-8;
    
            
            # max upload size
            client_max_body_size 75M;   # adjust to taste
    
            location /static {
                alias  /data/s4/deploy/uuuuuu; # 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
            }
        }
    }
    View Code
    Django部署:
        1. 租云服务器
        
        2. 买服务器
        
        
                租:公网IP,111.13.101.208
            租域名:www.pythonav.com <-> 111.13.101.208
        
        3. 编写代码
            
        
        4. 拷贝代码到服务器[Python,Django,pymysql,sqllite]
        
        
        5. 
            settings.py
                ALLOWED_HOSTS = ['服务器',]
            
            python manage.py runserver 0.0.0.0:8001
        
            使用:
                遵循wsig协议:
                    wsgiref
        6. uwsgi
            pip3 intall uwsgi 
            
            
            简单测试:
                app.py
                    def application(env, start_response):
                        start_response('200 OK', [('Content-Type','text/html')])
                        return [b"Hello World"]
                        
                uwsgi --http :9001 --wsgi-file app.py
    
                uwsgi --http :9002 --wsgi-file foobar.py --master --processes 4 --threads 2
                
            Django:
                
                # 不处理静态文件
                uwsgi --http :9002 --chdir /data/s4/deploy --wsgi-file deploy/wsgi.py --master --processes 4 --threads 2  
                
                
                
                STATICFILES_DIRS = (
                    os.path.join(BASE_DIR,'static'),
                )
                STATIC_ROOT = os.path.join(BASE_DIR,'uuuuuu')
                
                python manage.py collectstatic
                
                完事,注释静态配置
                
                # 处理静态文件
                uwsgi --http :9003 --chdir /data/s4/deploy --wsgi-file deploy/wsgi.py --static-map /static=/data/s4/deploy/uuuuuu
                
                
                # 写一个配置文件
                    wsgi_http.ini
                        [uwsgi]
                        http = 0.0.0.0:9004
                        chdir = /data/s4/deploy
                        wsgi-file = deploy/wsgi.py
                        # processes = 4
                        # threads = 2
                        static-map = /static=/data/s4/deploy/uuuuuu
                    uwsgi wsgi_http.ini
                    
        7. Nginx
            
            yum install nginx
            
            /etc/init.d/nginx start/stop/restart
            
            /etc/nginx/nginx.conf
            
            
            
            
            
            
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
                
                    
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
    View Code
    [uwsgi]
    socket = 127.0.0.1:8001
    chdir = /data/s4/deploy
    wsgi-file = deploy/wsgi.py
    # processes = 4
    # threads = 2
    static-map = /static=/data/s4/deploy/uuuuuu
    uwsgi

    bs4

    django

    Pillow
  • 相关阅读:
    生成Ptc文件时候使用top camera比较好
    3delight 上关于ptex的讨论,3delight的开发者最后说ptex的内存表现并不比普通的贴图差,不知道是不是因为3delight不支持而故意说的
    闲来无事,写个算法关于11000放在含有1001个元素。。。
    寻最优数字筛选算法找出 “排列数列“ 对应的 “组合数列“
    入住博客园
    日常工作中收集整理的MSSQL 技巧
    序列化 和 反序列化 类
    对Singleton Pattern的一点修改
    快速幂 & 取余运算 讲解
    JDK动态代理实现
  • 原文地址:https://www.cnblogs.com/golangav/p/8560190.html
Copyright © 2011-2022 走看看