beego项目部署

发布时间 2023-07-04 14:30:22作者: 不懂123

bee工具安装和升级 

     export GO111MODULE=on
     export GOPROXY=https://goproxy.cn

     go install github.com/beego/bee/v2@latest
     beego 必须是2.0以上的版本

     go mod tidy

      安装完之后,bee可执行文件默认存放在$GOPATH/bin里面,所以您需要把 $GOPATH/bin 添加到您的环境变量中

      

 bee操作项目命令

     bee new myproject
     bee generate routers
     bee fix
     bee update
     bee run
     bee run和go run main.go有区别

     

前端项目部署 

        

[root@ddos conf.d]# vi default.conf

server {
    listen       8000;
    server_name  localhost;

    #access_log  /var/log/nginx/host.access.log  main;

    location / {
        root   /usr/share/nginx/html/soms/dist;
        try_files $uri $uri/ @router;
        index  index.html index.htm;
    }

    location @router {
         rewrite ^.*$ /index.html last;
    }

    location /v1 {
         proxy_pass http://127.0.0.1:8889;
     }

    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }
}
虚拟主机1
[root@ddos conf.d]# vi suyuan.conf 

server {
    listen       8001;
    server_name  localhost;

    #access_log  /var/log/nginx/host.access.log  main;

    location / {
        root   /usr/share/nginx/html/suyuan/dist;
        try_files $uri $uri/ @router;
        index  index.html index.htm;
    }

    location @router {
         rewrite ^.*$ /index.html last;
    }

    location /v1 {
         proxy_pass http://127.0.0.1:8800;
     }

    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }
}
虚拟主机2       

     web访问服务