Linux部署说明.md 861 B

  1. 安装Go环境

去官网下载安装包 https://golang.google.cn/dl/

把下载好的安装包放到Linux服务器并用以下命令解压

tar -C /usr/local -xzf go1.17.7.linux-amd64.tar.gz
  1. 部署项目

把SmartBowGameServer目录放Linux服务器,在该目录下按顺序执行以下命令

  • 通过命令行临时设置环境变量(即关闭命令行后会失效)

    export PATH=$PATH:/usr/local/go/bin
    export GO111MODULE=on
    export GOPROXY=https://goproxy.cn
    
  • 运行项目

    nohup go run main.go
    
  1. 配置Nginx反向代理

    location /SmartBowGameServer {
    proxy_pass http://127.0.0.1:11811/SmartBowGameServer;
    
    # 主要websocket代理配置, $http_upgrade是指http协议头部Upgrade的值. 
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    }