Total Pageviews

Thursday, 8 May 2014

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

git clone https://github.com/turanct/bogl-me.git /usr/local/bogl && cd /usr/local/bogl && curl -sS https://getcomposer.org/installer | php && php composer.phar install && ln -s /usr/local/bogl/bogl.php /usr/local/bin/bogl

nano ~/.boglrc
内容为:
{
"ym bogl blog": {
"input": "/usr/local/bogl/content/",
"theme": "/usr/local/bogl/theme/",
"output": "/usr/local/bogl/html/"
}
}

cd /usr/local/bogl
rm -rf vendor
php composer.phar install
nano /usr/local/bogl/composer.json
(把"pimple/pimple": "dev-master",
替换为
"pimple/pimple": "1.1.x-dev",)
php composer.phar update
mkdir html

as3:/usr/local/bogl# ls
bogl.php       composer.lock  content  README.md  theme
composer.json  composer.phar  html     src        vendor
as3:/usr/local/bogl# cd content
as3:/usr/local/bogl/content# ls
config.json  pages  posts
as3:/usr/local/bogl/content# nano config.json
(把url的值改为你的域名地址,我暂时设为http://as3.brite.biz:29837,等下,我会
改为我的域名地址:http://bg.surmount.biz.wf,另外,可把home的值由static改为latest,并在下一行加上:
"latest": 3
这样,首页就将显示最近发表的3个帖子。
as3:/usr/local/bogl/content# cat config.json
{
        "title": "Bogl, the simple static markdown blog",
        "titleshort": "Bogl",
        "url": "http://bg.surmount.biz.wf",
        "rss": true,
        "home": "latest",        "latest": 3
}
as3:/usr/local/bogl/content#  )

发帖方法:
as3:/usr/local/bogl/content# cd posts
as3:/usr/local/bogl/content/posts# ls
chinese-economy.md  smiling-face.md  test-five.md  test-six.md
first-post.md       super-talk.md  
as3:/usr/local/bogl/content/posts# nano test-post.md
按first-post.md的格式,新建帖子test-post.md,格式如下:
测试帖
============== (“=”号的长度最好为标题长度的2倍或以上)

<p>这是一个测试帖子。</p>

<!-- DATE: 2014-05-08 12:36 -->
<!-- TAG: welcome -->
<!-- TAG: goodbye -->
<!-- CATEGORY: intro -->

然后,
as3:/usr/local/bogl/content/posts# bogl --site='ym bogl blog' (这个就是生成/更新静态网站的命令.或者返回/usr/local/bogl/,然后运行:
php bogl.php --input=/usr/local/bogl/content/ --theme=/usr/local/bogl/theme/ --output=/usr/local/bogl/html/也行。还可把
php bogl.php --input=/usr/local/bogl/content/ --theme=/usr/local/bogl/theme/ --output=/usr/local/bogl/html/ 保存为generate.sh文件,放在/usr/local/bogl/里面,以后,发帖后,运行这个sh文件,即可更新网站。
as3:/usr/local/bogl/content/posts# cd /usr/local/bogl/html/
as3:/usr/local/bogl/html# ls
404.html  assets  categories  feed.xml  index.html  pages  posts  tags
(可见/usr/local/bogl/html/就是静态网站的根目录)
as3:/usr/local/bogl/html# nohup Rwebserver 29837 > /dev/null &
访问http://as3.brite.biz:29837,http://as3.brite.biz:29837/posts/即可看到网站效果。

demo site: http://as3.brite.biz:29837,
http://bg.surmount.biz.wf,http://bg.surmount.biz.wf/posts/
项目地址:https://github.com/turanct/bogl-me/
https://github.com/turanct/bogl-me/issues/4