配置fastapi 及部署

https://fastapi.tiangolo.com/

 

指定端口/服务器/外网访问

# 指定端口
uvicorn main:app --host '0.0.0.0' --port 8080 --reload

 

 

问题

Command "/usr/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-aq6imxav/uvloop/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-jb_rshao-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-aq6imxav/uvloop/

sudo python -m pip install --upgrade --force pip

或者python3 -m ... 根据系统python版本    https://www.cnblogs.com/little-kwy/p/14941623.html

 

centos

https://www.cnblogs.com/wangjinyu/p/11679917.html

 一、防火墙的开启、关闭、禁用命令

(1)设置开机启用防火墙:systemctl enable firewalld.service

(2)设置开机禁用防火墙:systemctl disable firewalld.service

(3)启动防火墙:systemctl start firewalld

(4)关闭防火墙:systemctl stop firewalld

(5)检查防火墙状态:systemctl status firewalld 

二、使用firewall-cmd配置端口

(1)查看防火墙状态:firewall-cmd --state

(2)重新加载配置:firewall-cmd --reload

(3)查看开放的端口:firewall-cmd --list-ports

(4)开启防火墙端口:firewall-cmd --zone=public --add-port=9200/tcp --permanent

  命令含义:

  –zone #作用域

  –add-port=9200/tcp #添加端口,格式为:端口/通讯协议

  –permanent #永久生效,没有此参数重启后失效

  注意:添加端口后,必须用命令firewall-cmd --reload重新加载一遍才会生效

(5)关闭防火墙端口:firewall-cmd --zone=public --remove-port=9200/tcp --permanent

 

https://www.cnblogs.com/heqiuyong/p/10460150.html

1、开放端口

firewall-cmd --zone=public --add-port=5672/tcp --permanent   # 开放5672端口

firewall-cmd --zone=public --remove-port=5672/tcp --permanent  #关闭5672端口

firewall-cmd --reload   # 配置立即生效

2、查看防火墙所有开放的端口

firewall-cmd --zone=public --list-ports

3.、关闭防火墙

如果要开放的端口太多,嫌麻烦,可以关闭防火墙,安全性自行评估

systemctl stop firewalld.service

4、查看防火墙状态

 firewall-cmd --state

5、查看监听的端口

netstat -lnpt

PS:centos7默认没有 netstat 命令,需要安装 net-tools 工具,yum install -y net-tools

6、检查端口被哪个进程占用

netstat -lnpt |grep 1111

7、查看进程的详细信息

ps 6832

8、中止进程

kill -9 6832

posted @ 2021-07-27 10:14  西瓜皮不甜  阅读(2001)  评论(0编辑  收藏  举报