beego打包发布到Centos系统及国产麒麟系统完整教程

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

防火墙管理如下:

  1. 关闭防火墙,使用命令 systemctl stop firewalld
  2. 永久关闭, 执行命令 systemctl disable firewalld
  3. 关闭SELinux 临时关闭:运行命令 setenforce 0
  4. 永久关闭,打开/etc/selinux/config文件,将SELINUX=enforcing改为SELINUX=disabled
  5. 如果非要打防火墙及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