Python虚拟环境安装与配置项目启动

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/u010277446/article/details/84888923

一、概述

virtualenv,一个虚拟的python环境,一个专属于项目的python环境。

二、安装和配置

1.安装虚拟环境

  • 安装:pip3 install virtualenv
  • 创建:virtualenv venv -p /usr/bin/python3.5
  • 进入:source venv/bin/activate
  • 退出:deactivate

2.配置项目启动系统服务(虚拟环境)

[Unit]
Description=mc iotapios service
After=network.target

[Service]
User=root
Group=root
WorkingDirectory=/home/workspace/iotapios
Environment="PATH=/home/workspace/iotapios/venv/bin"
ExecStart=/home/workspace/iotapios/venv/bin/gunicorn --bind unix:/run/gunicorn/iot.sock -k gevent iotapios.wsgi

[Install]
WantedBy=multi-user.target

3.配置nginx.conf

upstream iotserver{
    server unix:/run/gunicorn/iot.sock fail_timeout=0;
}

server {
    listen 443 ssl ;
    server_name  www.example.com;
    ssl_certificate /etc/letsencrypt/live/www.example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/www.example.com/privkey.pem;
    ssl_session_tickets off;
    
    # auth let's encrypt SSL
	location ^~ /.well-known/acme-challenge/ {
        default_type "text/plain";
        root /home/workspace/www;
    }

    location = /.well-known/acme-challenge/ {
        return 404;
    }
    
    # custom....
    location / {
        try_files $uri @auth_success;
    }
}

猜你喜欢

转载自blog.csdn.net/u010277446/article/details/84888923
今日推荐