Beego learning 02, Beego deploy the project on-line

1, into the local project, and then execute the command

bee pack -be GOOS=linux

2, upload the resulting compressed files to the server, extract.

 

First, the project is to achieve access to go through nginx proxy, the official called the nginx deployment.

1, edit the file nginx.conf

2, add the following configuration

server {
    listen       8081;
    server_name  _;

    charset utf-8;
    access_log /data/wwwlogs/access_go.log combined;

    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://localhost:8080;
    }
}

意思是:监听8081端口的请求,然后反向代理到 http://localhost:8080。也可以配置域名,可以都是80的端口,通过不同的域名进行反向代理到不同的go项目。

3、阿里云和服务器防火墙开放端口

iptables -I INPUT 4 -p tcp -m state --state NEW -m tcp --dport 8081 -j ACCEPT && service iptables save

4、后台运行命令

nohup ./beepkg &

 

二:以下是直接访问go项目,官方叫做独立部署。

1、阿里云和服务器防火墙开放端口

iptables -I INPUT 4 -p tcp -m state --state NEW -m tcp --dport 8080 -j ACCEPT && service iptables save

因为go项目配置的8080端口,所以直接开放8080端口即可。

2、在 linux 下面部署,我们可以利用 nohup 命令,把应用部署在后端,如下所示:

nohup ./beepkg &

这样你的应用就跑在了 Linux 系统的守护进程

 

Guess you like

Origin www.cnblogs.com/edward1108/p/11237442.html