1、先清除go緩存,用下面命令
go clean -cache
go clean -modcache
2、更新庫文件
go mod tidy
3、安裝beego
go install github.com/beego/bee/v2@latest
4、查看bee版本
5、進行打包然后傳到Centos和麒麟服務器如下代碼
bee pack -be GOOS=linux -be GOARCH=amd64 //AMD64架構,一般Centos系統
bee pack -be GOOS=linux -be GOARCH=arm64 //ARM64架構,一般麒麟系統
6、最后寫在后面,后臺運行 go 及服務器關閉Selinx和防火墻
后臺運行如下命令: nohup ./go &
關閉直接殺死Pid就可以了,如下圖:ps aux | grep go
防火墻管理如下:
- 關閉防火墻,使用命令 systemctl stop firewalld
- 永久關閉, 執行命令 systemctl disable firewalld
- 關閉SELinux 臨時關閉:運行命令 setenforce 0
- 永久關閉,打開/etc/selinux/config文件,將SELINUX=enforcing改為SELINUX=disabled
- 如果非要打防火墻及SElinux,則需要把對應的端口開放,比如開放80,8080,8081等
????????sudo firewall-cmd --permanent --add-port=8081/tcp
????????sudo firewall-cmd --permanent --add-service=http
????????sudo firewall-cmd --permanent --add-service=https
????????# 重新加載防火墻
????????sudo firewall-cmd --reload