zoukankan      html  css  js  c++  java
  • Linux启动Django项目(nginx + uwsgi + django + BBS )

    步骤一、安装 python3 的环境

    yum install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel 
    sqlite-devel gcc gcc-c++  openssl-devel zlib zlib-devel python3 python3-devel -y
    

      

    步骤二、安装 Django 框架、uwsgi

    pip3 install -i https://mirrors.aliyun.com/pypi/simple/ --upgrade pip
    pip3 install -i https://mirrors.aliyun.com/pypi/simple/ django==1.11.9
    pip3 install -i https://mirrors.aliyun.com/pypi/simple/ uwsgi
    

      

    步骤三、配置Django工程

    [root@oldboy-pythonedu demosite]# cd /opt/
    [root@oldboy-pythonedu opt]# django-admin.py startproject demosite
    [root@oldboy-pythonedu opt]# cd demosite/
    [root@oldboy-pythonedu demosite]# python3 manage.py runserver 0.0.0.0:9999      # 启动测试
    

      

    步骤四、配置Django项目BBS、数据库

    vim BBS/BBS/settings.py 
    DATABASES = {
        'default': {
            'ENGINE': 'django.db.backends.mysql',
            'NAME': 'bbs',
            'HOST': '10.0.0.1',
            'PORT': 3306,
            'USER': 'all',
            'PASSWORD': "123456"}}
            
            
    # 数据库迁移
        cd /code/BBS
        python3 manage.py makemigrations
        python3 manage.py migrate
    ​
    # 创建超级用户
        python3 manage.py createsuperuser
    ​
    # 整合数据库静态文件
        python3 manage.py collectstatic
    

      

    步骤五、配置uwsgi

    vim bbs_uwsgi.ini
        [uwsgi]
        #uwsgi监听的端口
        socket = 127.0.0.1:8811
        chdir = /code/BBS/
        wsgi-file = BBS/wsgi.py
        #uwsgi启动进程数
        processes = 4
        threads = 10
        #最大接收的请求数
        max-requests = 1000
        #buffer缓冲区大小
        buffer-size = 30000
        #进程pid存放路径
        pidfile = /run/uwsgi-bbs.pid
        #uwsgi日志存储路径
        daemonize = /var/log/uwsgi-bbs.log
        
        
    ​
    ! 启动uwsgi服务
        uwsgi --ini /code/BBS/bbs_uwsgi.ini
    

      

    步骤六、配置nginx代理服务

    vim /etc/nginx/conf.d/bbs.com.conf 
    server {
        listen 80;
        server_name bbs.com;
        client_max_body_size 100M;
        location / {
        uwsgi_pass 127.0.0.1:8811;
        include uwsgi_params;}
    }
    

      

    域名解析,重载nginx

    C:WindowsSystem32driversetc
    10.0.0.201 bbs.com
    ​
    systemctl reload nginx
    

      

     

  • 相关阅读:
    Redis学习-发布/订阅
    Redis学习-Sentinel
    Redis学习-复制
    Redis学习-持久化
    Redis学习-Set
    Redis学习-SortedSet
    mac下使用apktool反编译
    ImageView setImageURI图片不改变NetWorkImageView 不显示的问题
    使用SharedPreference和对象流存储对象
    解决百度云推送通知,不显示默认Notification
  • 原文地址:https://www.cnblogs.com/zhoulangshunxinyangfan/p/13809615.html
Copyright © 2011-2022 走看看