centos7环境安装go语言环境+beego框架运行使用流程步骤
管理员 发布于 3年前   900
一.安装go环境
1.下载go语言安装包
wget https://dl.google.com/go/go1.15.6.linux-amd64.tar.gz
2.解压至/use/local/ 目录下
tar -C /usr/local/ -xzf go1.15.6.linux-amd64.tar.gz
3.创建及编辑配置文件 指定go的PATH路径
vim /etc/profile.d/go.sh
输入配置:
export PATH=$PATH:/usr/local/go/bin
4.让配置文件生效
source /etc/profile.d/go.sh
5.go环境就安装完了,看看效果
[root@iz8vbcrus31oj2axurgpjyz ~]# go version
go version go1.15.6 linux/amd64
二.安装beego框架
1.创建go项目目录/home/goblog/src/
2.设置配置文件
vim /etc/profile.d/go.sh
输入配置:
export GOROOT=/usr/local/go
export GOPATH=/home/goblog
export GOBIN=$GOPATH/bin
export PATH=$PATH:$GOROOT/bin:$GOBIN
export GO111MODULE="on"
export GOPROXY="https://goproxy.io"
3.让配置文件生效
source /etc/profile.d/go.sh
4.下载beego包及bee包
[root@iz8vbcrus31oj2axurgpjyz ~]# cd /home/goblog/
[root@iz8vbcrus31oj2axurgpjyz goblog]# go get github.com/astaxie/beego
go: downloading github.com/astaxie/beego v1.12.3
go: github.com/astaxie/beego upgrade => v1.12.3
...
[root@iz8vbcrus31oj2axurgpjyz goblog]# go get github.com/beego/bee
go: downloading github.com/beego/bee v1.12.3
go: github.com/beego/bee upgrade => v1.12.3
...
4.创建go项目,使用bee
[root@iz8vbcrus31oj2axurgpjyz ~]# cd $GOPATH/src
[root@iz8vbcrus31oj2axurgpjyz src]# ll
total 0
[root@iz8vbcrus31oj2axurgpjyz src]# bee new test
2021/01/07 13:46:31 INFO ▶ 0001 Getting bee latest version...
2021/01/07 13:46:32 WARN ▶ 0002 Update available 1.12.0 ==> 2.0.2
...
2021/01/07 13:46:32 SUCCESS ▶ 0007 New application successfully created!
5.运行beego框架
[root@iz8vbcrus31oj2axurgpjyz src]# cd test/
[root@iz8vbcrus31oj2axurgpjyz test]# go run main.go
go: finding module for package github.com/shiena/ansicolor
go: downloading gopkg.in/yaml.v2 v2.2.1
go: downloading github.com/shiena/ansicolor v0.0.0-20200904210342-c7312218db18
go: found github.com/shiena/ansicolor in github.com/shiena/ansicolor v0.0.0-20200904210342-c7312218db18
2021/01/07 13:48:45.473 [I] [asm_amd64.s:1374] http server Running on http://:8080
6.配置nginx , 创建配置文件:/use/local/nginx/conf/vhost/goblog.conf ,并添加一下配置信息
server {
listen 80;
server_name go.zongscan.com;
charset utf-8;
access_log /home/wwwlogs/go.log;
location /(css|js|fonts|img)/ {
access_log off;
expires 1d;
root "/gblog/static";
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;
}
}
7.添加解析,如果有购买域名直接用,如果没有的话就本地解析,添加hosts文件信息
windows7: C:\Windows\System32\drivers\etc
ip地址 go.zongscan.com
8.访问一下
请勿发布不友善或者负能量的内容。与人为善,比聪明更重要!
该博客于2020-12-7日,后端基于go语言的beego框架开发
前端页面使用Bootstrap可视化布局系统自动生成
是我仿的原来我的TP5框架写的博客,比较粗糙,底下是入口
侯体宗的博客
文章标签
友情链接