beego安装

环境:

操作系统centos6.7 x86-64
git客户端版本1.7.1
网络为办公网络(无法访问百度、腾讯、github.com等网站)
go版本1.7
已经在内网搭建好git server服务端,具备https和http以及ssh访问。但是都需要权限认证。

配置环境变量

1
2
3
4
5
6
7
[root@lwh goweb]# cat /etc/hosts
192.168.56.102 github.com
[root@lwh goweb]# export GOPATH=/root/goweb/
[root@lwh goweb]# git config --global user.name "git"
[root@lwh goweb]# git config --global http.sslVerify false
[root@lwh goweb]# git config --global credential.helper cache
[root@lwh goweb]# git config --global url."git@github.com:".insteadOf "https://github.com/"

下载beego

1
2
3
4
5
6
7
8
9
10
[root@lwh goweb]# go get -v github.com/astaxie/beego
github.com/astaxie/beego (download) The authenticity of host
'github.com (192.168.56.102)' can't be established. RSA key
fingerprint is 41:d0:8c:c6:37:34:a2:01:2a:69:6c:6a:19:1a:22:27. Are
you sure you want to continue connecting (yes/no)? yes
git@github.com's password: github.com/astaxie/beego/config
github.com/astaxie/beego/utils github.com/astaxie/beego/grace
github.com/astaxie/beego/logs github.com/astaxie/beego/session
github.com/astaxie/beego/toolbox github.com/astaxie/beego/context
github.com/astaxie/beego

下载bee

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
[root@lwh goweb]# go get -v github.com/beego/bee github.com/beego/bee
(download) git@github.com\'s password:
github.com/beego/bee/vendor/github.com/astaxie/beego/swagger
github.com/beego/bee/vendor/github.com/astaxie/beego/utils
github.com/beego/bee/vendor/golang.org/x/sys/unix
github.com/beego/bee/vendor/github.com/go-sql-driver/mysql
github.com/beego/bee/vendor/github.com/lib/pq/oid
github.com/beego/bee/vendor/github.com/lib/pq
github.com/beego/bee/vendor/github.com/jtolds/gls
github.com/beego/bee/vendor/github.com/smartystreets/assertions/internal/oglematchers
github.com/beego/bee/vendor/github.com/smartystreets/goconvey/convey/gotest
github.com/beego/bee/vendor/gopkg.in/yaml.v2
github.com/beego/bee/vendor/github.com/smartystreets/goconvey/convey/reporting
github.com/beego/bee/vendor/github.com/fsnotify/fsnotify
github.com/beego/bee/vendor/github.com/smartystreets/assertions
github.com/beego/bee/vendor/github.com/smartystreets/goconvey/convey
github.com/beego/bee

设置bee命令为系统命令

1
[root@lwh src]# export PATH=$PATH:$GOPATH/bin

建立一个demo

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
[root@lwh src]# bee new myfirst
2017/02/07 16:35:24 INFO ▶ 0001 Creating application... create /root/goweb/src/myfirst/
create /root/goweb/src/myfirst/conf/ create
/root/goweb/src/myfirst/controllers/ create
/root/goweb/src/myfirst/models/ create
/root/goweb/src/myfirst/routers/ create
/root/goweb/src/myfirst/tests/ create
/root/goweb/src/myfirst/static/ create
/root/goweb/src/myfirst/static/js/ create
/root/goweb/src/myfirst/static/css/ create
/root/goweb/src/myfirst/static/img/ create
/root/goweb/src/myfirst/views/ create
/root/goweb/src/myfirst/conf/app.conf create
/root/goweb/src/myfirst/controllers/default.go create
/root/goweb/src/myfirst/views/index.tpl create
/root/goweb/src/myfirst/routers/router.go create
/root/goweb/src/myfirst/tests/default_test.go create
/root/goweb/src/myfirst/main.go 2017/02/07 16:35:24 SUCCESS ▶ 0002
New application successfully created!

运行demo

1
2
3
4
5
6
7
8
9
10
11
12
[root@lwh src]# bee run myfirst
2017/02/07 16:37:12 INFO ▶ 0001 Using 'myfirst' as 'appname'
2017/02/07 16:37:12 INFO ▶ 0002 Loading configuration from 'Beefile'...
2017/02/07 16:37:12 INFO ▶ 0003 Initializing watcher...
2017/02/07 16:37:12 INFO ▶ 0004 Watching: /root/goweb/src/myfirst/controllers
2017/02/07 16:37:12 INFO ▶ 0005 Watching: /root/goweb/src/myfirst
2017/02/07 16:37:12 INFO ▶ 0006 Watching: /root/goweb/src/myfirst/routers
2017/02/07 16:37:12 INFO ▶ 0007 Watching: /root/goweb/src/myfirst/tests
2017/02/07 16:37:17 SUCCESS ▶ 0008 Built Successfully!
2017/02/07 16:37:17 INFO ▶ 0009 Restarting 'myfirst'...
2017/02/07 16:37:17 SUCCESS ▶ 0010 './myfirst' is running...
2017/02/07 16:37:17 [I] [asm_amd64.s:2197] http server Running on http://:8080

最终运行结果如下,嘿嘿,不容易啊

坚持原创技术分享,如果觉得文章对你有帮助,给点鼓励更好!