指定端口/服務器/外網訪問
# 指定端口 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