美文网首页
Beego打包部署(独立部署)

Beego打包部署(独立部署)

作者: qqhaodong | 来源:发表于2019-03-12 15:55 被阅读0次
    1. 该方法在已安装ubuntu+nginx下完成的。

    2. 打包你的beego项目

    bee pack -be GOOS=linux
    
    1. 解压并且通过ftp(FileZilla)工具存储到你的gopath文件夹下,我的目录是
    /home/ubuntu/go/src
    
    1. 需要注意的是该文件目录需要释放权限
    sudo chmod 777 /home/ubuntu/go/src
    
    1. 通过命令到该项目文件夹中(www_home是该项目文件名)
    cd /home/ubuntu/go/src/www_home
    
    1. 运行nohup命令
    nohup ./www_main &
    
    1. 将conf.d文件权限打开
    sudo chmod 777 /etc/nginx/conf.d
    
    1. 进入到该文件中 vim sever.conf文件

    2. 在该文件编辑如下信息

    server {
        listen       80;
        server_name  www.qmystudio.com; #你的域名
    
        charset utf-8;
        access_log  /home/ubuntu/go/src/www_main/access.log; #该目录建议是你的部署文件目录
    
        location /(css|js|fonts|img)/ {
            access_log off;
            expires 1d;
    
            root "/home/ubuntu/go/src/www_main/static";#该文件是你index的文件位置,默认在view中的tpl文件
            try_files $uri @backend;
        }
    
        location / {
            try_files /_not_exists_ @backend;
        }
    
        location @backend {
            proxy_set_header X-Forwarded-For $remote_addr;
            proxy_set_header Host            $http_host;
    
            proxy_pass http://127.0.0.1:8080;
        }
    }
    
    1. Esc -> :wq 保存该配置文件

    2. 需要找到ngin位置

    which nginx
    
    1. 重启 nginx,我的目录是/usr/sbin/nginx
    sudo /usr/sbin/nginx  -s reload
    
    1. 大功告成!访问你的项目即可!

    相关文章

      网友评论

          本文标题:Beego打包部署(独立部署)

          本文链接:https://www.haomeiwen.com/subject/nidnpqtx.html