python3 supervisor api接口_ubutu tornado python3.7.5 nginx supervisor 部署web api

本文介绍了在Ubuntu环境中使用Python3.7.5安装Tornado、torndb以及解决安装过程中遇到的问题,如缺失模块。接着展示了如何配置Nginx反向代理Tornado API服务,以及通过Supervisor管理Tornado进程。文章还包含了Supervisor的配置文件示例和启动命令。
摘要由CSDN通过智能技术生成

环境:

1、Ubuntu 服务器

2、python3.7.5

安装

1、python3.7.5

安装的话还是比较简单,流程大致是

./configure ->make && make install ->创建python软连接  pip软连接

安装起来倒是简单,安装完成运行才会遇到各种各样的问题,缺少插件啥的。

1.1、下载包  python3.7.5

1.2、问题

a、No module named '_ctypes'

sudo apt-get install libffi-dev 需不需要重新安装看ok不

b、No module named _ssl

安装之前修改下安装包里面的modules里面的setup.dist文件的内容

ex:  /usr/web/tornadoTest/package/Python-3.7.5/Modules/Setup.dist   我的安装目录

大约 206行左右,去掉注释即可

然后再重新安装,等pip这些可以用起来了在开始下一步。

2、安装所需的package

需要的包有mysqldb  tornado  torndb,看你用的是pymysql还是mysqldb

2.1  普通安装  pip install

2.2 mysqldb 安装

安装mysqldb 之前需要配置mysql_config

sudo apt-get install libmysqlclient-dev

sudo apt-get install python-dev

然后安装。

3、启动错误

3.1 torndb的错误

if MySQLdb is not None:

# Fix the access conversions to properly recognize unicode/binary

FIELD_TYPE = MySQLdb.constants.FIELD_TYPE

FLAG = MySQLdb.constants.FLAG

CONVERSIONS = copy.copy(MySQLdb.converters.conversions)

field_types = [FIELD_TYPE.BLOB, FIELD_TYPE.STRING, FIELD_TYPE.VAR_STRING]

if 'VARCHAR' in vars(FIELD_TYPE):

field_types.append(FIELD_TYPE.VARCHAR)

#for field_type in field_types:

# CONVERSIONS[field_type] = [(FLAG.BINARY, str)] + CONVERSIONS[field_type]

注释掉这个

3.2 然后启动成功查询数据时可能还会原道这种错误。

https://www.cnblogs.com/simplezhuo/p/9811369.html

4、nginx 配置

4.1、tornado服务可以运行

python server.py --port 8888

nohup python server.py 登出也不会停止。

4.2、配置

default.conf

##

# You should look at the following URL's in order to grasp a solid understanding

# of Nginx configuration files in order to fully unleash the power of Nginx.

# http://wiki.nginx.org/Pitfalls

# http://wiki.nginx.org/QuickStart

# http://wiki.nginx.org/Configuration

#

# Generally, you will want to move this file somewhere, and start with a clean

# file but keep this around for reference. Or just disable in sites-enabled.

#

# Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.

##

# Default server configuration

#

upstream tornados{

server 127.0.0.1:8888;

}

proxy_next_upstream error;

server {

listen 80 default_server;

listen [::]:80 default_server;

# SSL configuration

#

# listen 443 ssl default_server;

# listen [::]:443 ssl default_server;

#

# Note: You should disable gzip for SSL traffic.

# See: https://bugs.debian.org/773332

#

# Read up on ssl_ciphers to ensure a secure configuration.

# See: https://bugs.debian.org/765782

#

# Self signed certs generated by the ssl-cert package

# Don't use them in a production server!#

# include snippets/snakeoil.conf;

# Add index.php to the list ifyou are using PHP

index index.html index.htm index.nginx-debian.html;

server_name111.231.201.164;

location/cnc/1/{

alias/usr/web/cnc/;

index index.html index.htm;

}

location/cnc/2/{

alias/usr/web/cnc/;

index index.html index.htm;

}

location/cnc/3{

alias/usr/web/cnc/;

index index.html index.htm;

}

location/cnc/4{

alias/usr/web/cnc/;

index index.html index.htm;

}

location/cnc/5{

alias/usr/web/cnc/;

index index.html index.htm;

}

location/cnc/6{

alias/usr/web/cnc/;

index index.html index.htm;

}

location/cnc/7{

alias/usr/web/cnc/;

index index.html index.htm;

}

location/api/{

allow111.231.201.164;

proxy_pass_header Server;

proxy_set_header Host $http_host;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值