Pages

Tuesday, 22 October 2013

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

as3:~# npm install -g nirman
as3:~# mkdir nirman-site
as3:~# cd nirman-site
as3:~/nirman-site# nirman --new (这个就是新建静态网站的命令)
as3:~/nirman-site# nirman
Working on directory:  /root/nirman-site
Started rendering...
Render complete!
Server running at: http://localhost:8888
as3:~/nirman-site# nohup nirman > /dev/null &
[1] 18496
as3:~/nirman-site# nohup: ignoring input and redirecting stderr to stdout
(上述命令:nohup nirman > /dev/null &会在当前目录下,生成build目录,build目录-~/nirman-site/build/就是静态网站的根目录,你可绑定一个域名到该目录。)
as3:~/nirman-site# ls
build  config.yaml  contents  layouts
as3:~/nirman-site# ls build
404.html       favicon.ico  page2.html  posts                static
about-us.html  index.html   page3.html  privacy-policy.html  tag
as3:~/nirman-site#

发贴方法:
as3:~/nirman-site/contents/posts# ls
awesome-post.md               mit-license.md             showdown.md
jquery-file-upload-plugin.md  nirman.md                  test1.md
libgit2.md                    quick-markdown-example.md
markdown.md                   semantic-ui.md

按~/nirman-site/contents/posts/里面的某个md文件,依样画葫芦,新建帖子test1.md,格式如下:
---
title: test1(测试1)
layout: post
tags: static, site, generator, flexible, nirman, awesome, misc
---
这是测试1.


保存更改。然后:
as3:~/nirman-site/contents/posts# cd ~/nirman-site/
as3:~/nirman-site# nirman (这个就是更新静态网站的命令)

演示站点:http://as3.brite.biz:8888/,http://nm.brite.biz (这里,绑定了域名后,访问网站里的帖子有问题-内容不能显示。原来其原因跟ussm的问题起因http://briteming.blogspot.co.uk/2013/10/linux-vpsocaml-ussm.html 是一样的:
 <VirtualHost 178.17.40.78:80>
ServerName nm.brite.biz
DocumentRoot /root/nirman-site/build/
<Directory /root/nirman-site/build/>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride All
            Order allow,deny
            allow from all
        </Directory>

</VirtualHost>
需加上上述蓝色部分,重启apache即可。如果是nginx webserver,我还需测试一下如何做。
项目地址:https://github.com/anupshinde/nirman