Total Pageviews

Wednesday, 2 April 2014

在linux vps上搭建基于go的静态博客程序-gablog

git clone https://github.com/bketelsen/gablog
cd gablog/cmd/blog/
go get -d
go build
cd ../..
nohup ./cmd/blog/blog -http=:8003 > /dev/null &
访问http://as3.brite.biz:8003就可看到网站效果。

发贴方法:
as3:~/gablog# cd content
as3:~/gablog/content# cat scholarship-for-women.article
GopherCon 2014 Scholarship for Women
15 Jan 2014
Tags: gophercon scholarship

Brian Ketelsen

* Announcing the GopherCon Scholarship Program

Today I'd like to announce。。。
as3:~/gablog/content# nano test1.article
按~/gablog/content/里的scholarship-for-women.article的内容格式,新建帖子test1.article,格式如下:
测试1 (这是标题)
23:55 2 Apr 2014 (注意:这里不要写为02 April 2014.不要省略23:55,否则发表的帖子不会按时间顺序排列)
Tags: misc

ym (这是文章作者的名字)

* 测试1 (注意:此行一定要写上。我之前省略了此行,就遇到错误了)

这是测试1.


保存更改,网站就自动更新了。如果要插入html code,是不能在“这是测试1.”这行直接插入的,需如下操作:
新建帖子mother-s-kiss.article,格式如下:
妈妈的吻 (这是标题)
2 Apr 2014 (注意:这里不要写为02 April 2014)
Tags: misc

ym (这是文章作者的名字)

* 妈妈的吻 (注意:此行一定要写上。我之前省略了此行,就遇到错误了)

.html mother-s-kiss.html

然后在~/gablog/content/里面新建mother-s-kiss.html,内容为你要插入的html code:
<object data="http://tilidom.com/dewplayer/dewplayer.swf?id=28264&amp;token=BC060DAE9&amp;mp3=http://tilidom.com/tilidom/download/tiliplayer?file_id=758427&amp;autoreplay=1" type="application/x-shockwave-flash" height="40" width="240">
<param value="transparent" name="wmode">
<param value="http://tilidom.com/dewplayer/dewplayer.swf?id=28264&amp;token=BC060DAE9&amp;mp3=http://tilidom.com/tilidom/download/tiliplayer?file_id=758427&amp;autoreplay=1" name="movie"></object>
保存更改,网站就自动更新了。
参考http://godoc.org/code.google.com/p/go.tools/present

演示站点: http://as3.brite.biz:8003/,若要绑定域名,就只能用apache/nginx做反向代理,来反向代理网址http://as3.brite.biz:8003/的方式实现。
程序作者搭建的博客:http://blog.gopheracademy.com/
项目地址:https://github.com/bketelsen/gablog
-------------------------------------------------------------
当然也可按以前建立go博客的方式来做:
cd ~/mygo
as3:~/mygo# go get -d github.com/bketelsen/gablog
as3:~/mygo# ls src/github.com/bketelsen/gablog
AUTHORS  content       LICENSE     PATENTS  README.md  static   template
cmd      CONTRIBUTORS  nginx.conf  pkg      staging    support
(这里,~/mygo/src/github.com/bketelsen/gablog/就是克隆下来的源码目录)
as3:~/mygo# go install github.com/bketelsen/gablog/cmd/blog/
(这一步就安装好了)
as3:~/mygo# cd src/github.com/bketelsen/gablog 
as3:~/mygo/src/github.com/bketelsen/gablog# blog
2014/01/24 09:39:30 Now listening on localhost:9003
2014/01/24 09:39:30 listen tcp 127.0.0.1:9003: address already in use
(以上提示说明9003端口被以前的某个程序占用)
as3:~/mygo/src/github.com/bketelsen/gablog# blog -http=:7003
2014/01/24 09:43:48 Now listening on :7003
按ctrl+c退出控制台。
as3:~/mygo/src/github.com/bketelsen/gablog# nohup blog -http=":7003" > /dev/null & 
访问http://as3.brite.biz:7003/就可看到网站效果。 

发贴方法:
 as3:~/mygo/src/github.com/bketelsen/gablog# cd content
as3:~/mygo/src/github.com/bketelsen/gablog/content# cat scholarship-for-women.article
GopherCon 2014 Scholarship for Women
15 Jan 2014
Tags: gophercon scholarship

Brian Ketelsen

* Announcing the GopherCon Scholarship Program

Today I'd like to announce...
as3:~/mygo/src/github.com/bketelsen/gablog/content# nano test1.article
按scholarship-for-women.article的内容格式,新建帖子test1.article,格式如下:
测试1 (这是标题)
2 Apr 2014
Tags: misc

ym (这是文章作者的名字)

* 测试1

这是测试1.


保存更改,网站就自动更新了。

演示站点:http://as3.brite.biz:7003/
项目地址:https://github.com/bketelsen/gablog