Pages

Friday, 8 November 2013

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

mkdir phase-site
cd phase-site
git clone git://github.com/cakephp/cakephp.git
cd cakephp
git clone git://github.com/AD7six/phase.git
cd phase
git submodule update --init --recursive
cp Config/core.php.default Config/core.php
cp -R Skel Site

as3:~/phase-site/cakephp/phase# ls
Config   Controller  LICENSE  README.md  Skel  Vendor  webroot
Console  index.php   Model    Site       tmp   View
as3:~/phase-site/cakephp/phase# Console/cake phase
显示:
Manage your phase-built site
Usage:
cake phase [subcommand] [-h] [-v] [-q]
Subcommands:
write   Create a new post. (cake phase write  创建新帖子)
build   Generate a static version of your application. (cake phase build 生成静态网站)
deploy  Copy files to public server. (cake phase deploy 部署到外部的服务器)
To see help on a subcommand use `cake phase [subcommand] --help`
Options:
--help, -h     Display this help.
--verbose, -v  Enable verbose output.
--quiet, -q    Enable quiet output.
as3:~/phase-site/cakephp/phase# Console/cake phase write test1 (这里test1为帖子的slug)
Welcome to CakePHP v2.4.2 Console
---------------------------------------------------------------
App : phase
Path: /root/phase-site/cakephp/phase/
---------------------------------------------------------------
2013-11-02-test1.md created
as3:~/phase-site/cakephp/phase# find ~/phase-site/ -name 2013-11-02-test1.md
/root/phase-site/cakephp/phase/Site/Views/Posts/2013-11-02-test1.md
as3:~/phase-site/cakephp/phase# nano Site/Views/Posts/2013-11-02-test1.md
as3:~/phase-site/cakephp/phase# Console/cake phase build (这个就是生成/更新静态网站的命令)
(如果遇到错误:
PHP Parse error: syntax error, unexpected T_STRING in /root/phase-
site/cakephp/phase/View/Layouts/xml/atom.ctp on line 1
Fatal Error Error: syntax error, unexpected T_STRING in [/root/phase-
site/cakephp/phase/View/Layouts/xml/atom.ctp, line 1]
Parse error: syntax error, unexpected T_STRING in /root/phase-
site/cakephp/phase/View/Layouts/xml/atom.ctp on line 1
则mv /root/phase-site/cakephp/phase/View/Layouts/xml/atom.ctp /root/phase-site/cakephp/phase/View/Layouts/xml/atom.ctp.bak,或者删除atom.ctp)
然后再次:
as3:~/phase-site/cakephp/phase# Console/cake phase build
as3:~/phase-site/cakephp/phase# ls publish
2013                                      crossdomain.xml
404.html                                  css
about.html                                empty
apple-touch-icon-114x114-precomposed.png  favicon.ico
apple-touch-icon-57x57-precomposed.png    humans.txt
apple-touch-icon-72x72-precomposed.png    img
apple-touch-icon.png                      index.html
apple-touch-icon-precomposed.png          js
archives.html                             robots.txt
so,~/phase-site/cakephp/phase/publish就是静态网站的根目录。

项目地址:https://github.com/AD7six/phase
演示站点:http://ps.brite.biz/