Total Pageviews

Saturday 18 February 2017

搭建基于php的静态博客程序JustWriting

首先搭建php环境,PHP 5.3.6+

cd /usr/local
git clone https://github.com/hjue/JustWriting justwriting-site
cd  justwriting-site

root@AR:/usr/local/justwriting-site# ls
LICENSE       composer.json  index.php         settings.php          tests
README.md     config.yaml    install.php     settings_sample.php
README.zh.md  css         phpunit.xml     styles
api.md          docs         posts         system
application   favicon.ico    sae_app_wizard.xml  templates
(可见/usr/local/justwriting-site就是静态网站的根目录。你需绑定你的域名到该目录,并设置该目录为你的虚拟主机的根目录)
root@AR:/usr/local/justwriting-site# nano settings.php
($blog_config['duoshuo_short_name']的值改为你的duoshuo id.
$blog_config['base_url']的值改为你的域名地址,不要加上斜杠,我的为http://jw.bright.biz.st
$blog_config['posts_per_page']的值改为3 )

 关于虚拟主机的根目录的设置:
如果你的webserver程序为apache:
首先启用rewrite模块,命令为a2enmod rewrite ,参见http://www.111cn.net/phper/apache/54086.htm;如果apache是编译的,则参考http://www.phpxs.com/post/1333/ ,
先删除 /usr/local/justwriting-site目录下的.htaccess文件。
编辑apache的配置文件,插入如下虚拟主机代码:
<VirtualHost *:80>
DocumentRoot /usr/local/justwriting-site
ServerName jw.bright.biz.st
<Directory />
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order deny,allow
Allow from all
</Directory>
<Files ~ "\.md$">
order allow,deny
deny from all
</files>
RewriteEngine on
RewriteCond $1 !^/(index\.php|css|highlight|images|posts|templates|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
</VirtualHost>

 如果你的webserver为nginx,则编辑nginx的配置文件如下(参见https://gist.github.com/hjue/647dc694dc3b67994202):
server_name的值改为你的域名
root的值改为/usr/local/justwriting-site

新建源帖:
root@AR:/usr/local/justwriting-site# cd posts
root@AR:/usr/local/justwriting-site/posts# nano test-1.md
root@AR:/usr/local/justwriting-site/posts# cat test-1.md
Date: 2017-02-19
Title: 测试1
intro: 点击标题,看全文
Tags: misc1 misc2 misc3
Status: public

这是测试1.

看看如何?

root@AR:/usr/local/justwriting-site/posts#

源帖一创建完毕,网站就自动更新了。

演示网站:http://jw.bright.biz.st/
项目地址:https://github.com/hjue/JustWriting

No comments:

Post a Comment