美文网首页
2019-08-18 上线记录

2019-08-18 上线记录

作者: 早起早起早起up | 来源:发表于2019-10-11 14:55 被阅读0次

    1.安装各种依赖在centos 上   yum install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel gcc  gcc-c++ openssl-devel libffi-devel  python-devel mariadb-devel

    2.下载python 源码进行安装

    wget  https://www.python.org/ftp/

    tar -xzvf  python

    cd 

    3. 把python 安装到 /usr/local 目录下

    ./configure --prefix=/usr/local/python3

    make

    make install

    ---------

    4.更改/usr/bin/python3 连接

    ln -s /usr/local/bin/python3.7 /usr/bin/python3

    ln -s /usr/local/bin/pip3.7 /usr/bin/pip3

    5.安装nginx

    sudo  yum install epel-release

    sudo yum install nginx

    sudo systemctl start nginx

    6.安装virtualenvwrapper

    正确

    # 查找python3命令的路径

    [root@instance-nnja0or7 ~]# which python3

    /opt/python3/bin/python3

    # 查找virtualenvwrapper.sh脚本的路径

    [root@instance-nnja0or7 ~]# find / -name virtualenvwrapper.sh

    /opt/python3/bin/virtualenvwrapper.sh

    vim ~/.bashrc

    # 末尾添加以下代码,保存退出

    WORKON_HOME=~/Envs 

    VIRTUALENVWRAPPER_VIRTUALENV_ARGS='--no-site-packages'

    VIRTUALENVWRAPPER_PYTHON=/opt/python3/bin/python3

    source /opt/python3/bin/virtualenvwrapper.sh

    #设置virtualenv的统一管理目录,以后自动下载的虚拟环境都放在这

    WORKON_HOME=~/Envs 

    #添加virtualenvwrapper的参数,生成干净隔绝的环境

    VIRTUALENVWRAPPER_VIRTUALENV_ARGS='--no-site-packages'

    #指定python解释器的本体

    VIRTUALENVWRAPPER_PYTHON=/opt/python3/bin/python3

    #执行virtualenvwrapper安装脚本

    source /opt/python3/bin/virtualenvwrapper.sh

    正确结束

    export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3

    yum install python-setuptools python-devel

    pip install virtualenvwrapper

    vi ~/.bashrc

    export WORKON_HOME=$HOME/.virtualenvs

    source /usr/bin/virtualenvwrapper.sh

    首先你是看下你的那个virtualenvwrapper.sh在哪

    find / -name virtualenvwrapper.sh

    export WORKON_HOME=/root/envss

    export VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python3

    source /usr/local/bin/virtualenvwrapper.sh

    重新加载.bashrc文件

    source ~/.bashrc

    mkvirtualenv mxonline

    pip install -r requirements.txt

    5. 安装uwsgi

    pip install uwsgi

    6. 测试uwsgi  在根目录

    uwsgi --http :8000 --module MxOnline.wsgi

    然后可以进行访问 ;加端口8000

    7.通过配置文件启动uwsgi

    新建uwsgi.ini 配置文件, 内容如下:

        # mysite_uwsgi.ini file

        [uwsgi]

        # Django-related settings

        # the base directory (full path)

        chdir          = /home/bobby/Projects/MxOnline

        # Django's wsgi file

        module          = MxOnline.wsgi(setting那个  )

        # the virtualenv (full path)

        # process-related settings

        # master

        master          = true

        # maximum number of worker processes

        processes      = 10

        # the socket (use the full path to be safe

        socket          = 127.0.0.1:8000(与nginx 一致)

        # ... with appropriate permissions - may be needed

        # chmod-socket    = 664

        # clear environment on exit

        vacuum          = true

        virtualenv = /home/bobby/.virtualenvs/mxonline

    (查看virtualenv   ls ~/.virtualenvs/

    cd  dsrl

    pwd

        logto = /tmp/mylog.log  日志文件

    注:

        chdir: 表示需要操作的目录,也就是项目的目录

        module: wsgi文件的路径

        processes: 进程数

        virtualenv:虚拟环境的目录

    (启动uwsgi   nohup  uwsgi -i uwsgi.ini  &    注意是进入uwsgi    workon  dslr)

    7. 配置nginx

    /etc/nginx/nginx.conf,然后进入编辑模式,改完:wq退出

    user nginx 改为 user root

    新建uc_nginx.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:8000; # for a web port socket (we'll use this first)   这个是我们8000需要与uwsgi 一致

    }

    # configuration of the server

    server {

    # the port your site will be served on

    listen      80;

    # the domain name it will serve for

    server_name  154 ; # 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 /media  {

        alias 你的目录/Mxonline/media;  # 指向django的media目录

    }

    location /static {

        alias 你的目录/Mxonline/static; # 指向django的static目录

    }

    # Finally, send all non-media requests to the Django server.

    location / {

        uwsgi_pass  django;

        include    uwsgi_params; # the uwsgi_params file you installed

    }

    }

    cp uc.conf /etc/nginx/conf.d/  复制到

    9. 运行nginx

    sudo /usr/sbin/nginx  或者nginx

    10.配置static

    在django的setting文件中,添加下面一行内容:

        STATIC_ROOT = os.path.join(BASE_DIR, "static/")

    运行命令

        python manage.py collectstatic

    11.重新运行uwsgi

    pkill -f uwsgi

    12.域名  https  证书购买

    申请配置  Csymtec 单域名  免费行

    相关文章

      网友评论

          本文标题:2019-08-18 上线记录

          本文链接:https://www.haomeiwen.com/subject/zoadsctx.html