Total Pageviews

Wednesday, 1 January 2014

在linux vps上,搭建基于php的静态博客程序-spress

git clone https://github.com/yosymfony/Spress.git spress
cd spress
curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin/
(此命令用来安装composer.phar程序)
composer.phar update
ln -s ~/spress/bin/spress /usr/local/bin/spress
as3:~/spress# spress site:new spress-site (此命令会在当前目录下,生成spress-site目录)
as3:~/spress# cd spress-site
as3:~/spress/spress-site# spress site:build -s .
会显示:
Starting...
Total posts: 0
Processed posts: 0
Drafts post: 0
Total pages: 1
Processed pages: 0
Other resources: 0
as3:~/spress# cd spress-site
as3:~/spress/spress-site# ls
config.yml  index.html  _layouts  _posts  _site
as3:~/spress/spress-site# cd _site
as3:~/spress/spress-site/_site# ls
index.html
as3:~/spress/spress-site/_site#
可见~/spress/spress-site/_site/就是静态网站的根目录。

git clone https://github.com/yosymfony/Spress-example.git
cd Spress-example
spress site:build -s .
具体为:
as3:~/Spress-example# ls
404.html  config.yml  index.html  _posts     res
about     _includes   _layouts    README.md  sitemap.xml
as3:~/Spress-example# spress site:build -s . (这个就是生成/更新静态网站的命令)
Starting...
Total posts: 4
Processed posts: 4
Drafts post: 0
Total pages: 7
Processed pages: 4
Other resources: 4
as3:~/Spress-example# ls
404.html  config.yml  index.html  _posts     res    sitemap.xml
about     _includes   _layouts    README.md  _site
as3:~/Spress-example# cd _site
as3:~/Spress-example/_site# ls
2013  404.html  about  index.html  page2  res  sitemap.xml
as3:~/Spress-example/_site#
可见~/Spress-example/_site/就是静态网站的根目录。
as3:~/Spress-example/_site# nohup Rwebserver 23651 > /dev/null &
访问http://as3.brite.biz:23651/,就可看到网站效果。
发贴方法:
as3:~/Spress-example/_site# cd ../_posts
as3:~/Spress-example/_posts# ls
2013-10-04-tables.md  2013-10-05-your-text.md  2014-1-2-test1.md
2013-10-05-videos.md  2013-10-06-hello.md     
按2013-10-06-hello.md的格式,新建帖子2014-01-02-test2.md,格式为:
---
title: 测试2(test2)
layout: post
disqus_comments: true
---

这是测试2.

 (以上的标题最好中英文混合。否则文章的超链会有问题)
然后:
as3:~/Spress-example/_posts# cd ..
as3:~/Spress-example# spress site:build -s .

演示站点:http://as3.brite.biz:23651/,http://spress.brite.biz/
http://yosymfony.github.io/Spress-example/
项目地址:https://github.com/yosymfony/Spress
https://github.com/yosymfony/Spress-example