Total Pageviews

Sunday, 13 April 2014

在linux vps上搭建基于nodejs的静态博客程序:poet

git clone https://github.com/jsantell/poet
cd poet
nano package.json
在"fs-then": "0.1.x"的上一行加上"poet": "", (逗号不可少)
把"express"那行改为"express": "3.x.x"
然后运行npm install

as3:~/poet# cd examples
as3:~/poet/examples# ls
configuredSetup.js  public      views
customRoutes.js     package.json  rss.js      watcher.js
defaultSetup.js     _posts        sitemap.js
as3:~/poet/examples# nano package.json
as3:~/poet/examples# cat package.json
{
  "name": "PoetExamples",
  "version": "0.0.1",
  "engines": ["node >= 0.6.12"],
  "private" : true,
  "dependencies":
  {
    "express":          "3.x.x",
    "poet":             "",
    "jade" :            ">= 0.20.3"
  }
}
(注意:修改了"express"的值,并加上了"poet": "",)
as3:~/poet/examples# npm install
as3:~/poet/examples# npm install routes
as3:~/poet/examples# nano defaultSetup.js
把app.listen(3000);改为app.listen(3025);
as3:~/poet/examples# nohup node defaultSetup.js > /dev/null &
访问http://as3.brite.biz:3025/即可看到网站效果。

发贴方法:
as3:~/poet/examples# ls
configuredSetup.js  node_modules  public      views
customRoutes.js     package.json  rss.js      watcher.js
defaultSetup.js     _posts        sitemap.js
as3:~/poet/examples# cd _posts
as3:~/poet/examples/_posts# ls
acidcupcakecolourscheme.md  jquery-twitch.md           node-request-extend.md
dancer.js.md                js-image-diff.md
flotr2.md                   node-json-front-matter.md
as3:~/poet/examples/_posts# nano test1.md
格式为:
{{{
    "title": "test1",
    "tags": ["charts", "graph", "canvas"],
    "category": "misc",
    "date": "4-13-2014 18:46:00"
}}}

<h2>测试1</h2>
这是测试1.

然后,(注意:这里不同于http://briteming.blogspot.co.uk/2014/04/linux-vpsnodejsmyallbluewebsite.html的做法,不是保存帖子后,就了事的。保存帖子后,网站不能自动更新,还需操作如下)
as3:~/poet/examples/_posts# cd ..
as3:~/poet/examples# ls
configuredSetup.js  node_modules  public      views
customRoutes.js     package.json  rss.js      watcher.js
defaultSetup.js     _posts        sitemap.js
as3:~/poet/examples# netstat -anp|grep :3025
tcp        0      0 0.0.0.0:3025            0.0.0.0:*               LISTEN      13520/node
tcp        0      0 178.17.41.213:56645     178.17.41.213:3025      ESTABLISHED 8950/sshd: surmount
tcp        0      0 178.17.41.213:3025      178.17.41.213:56645     ESTABLISHED 13520/node
as3:~/poet/examples# kill 13520
as3:~/poet/examples# nohup node defaultSetup.js > /dev/null &

演示站点:http://as3.brite.biz:3025/
项目地址:https://github.com/jsantell/poet
此站点http://andreasklein.org/就是用poet搭建的, 网站源码:https://github.com/ixisio/andreasklein_org

 相关帖子:http://briteming.blogspot.co.uk/2014/04/linux-vpsnodejsmyallbluewebsite.html,这个myallblue_website程序其实修改自poet.