VPS上配置Git+Octopress

终于用了一整天的时间,把博客从Wordpress换到了Octopress。我是希望在本地能不装ruby但是服务器能自动更新,并且希望支持历史版本,在网上找了一整天也试了一整天,整理出下面代码备忘:

Create git repository on VPS
1
2
3
4
5
6
server$ cd ~
server$ mkdir oi.abcdabcd987.com.git
server$ cd oi.abcdabcd987.com.git
server$ git init --bare
server$ pwd
/home/quartergeek/oi.abcdabcd987.com.git
Install Octopress on VPS
1
2
3
4
5
6
7
8
9
10
11
server$ cd /tmp
server$ git clone git://github.com/imathis/octopress.git octopress
server$ cd octopress
server$ bundle install
server$ rake install
server$ git add .
server$ git commit -m 'init octopress'
server$ git remote rename origin octopress
server$ git remote add origin /home/quartergeek/oi.abcdabcd987.com.git
server$ git config branch.master.remote origin
server$ git push origin master
Setup auto generate on VPS
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
server$ cd /home/quartergeek/oi.abcdabcd987.com.git
server$ echo <<EOF > hooks/post-receive
> #!/bin/bash -l
> GIT_REPO=/home/quartergeek/oi.abcdabcd987.com.git
> TMP_GIT_CLONE=/tmp/oi.abcdabcd987.com
> PUBLIC_WWW=/home/wwwroot/oi.abcdabcd987.com/octopress
> 
> git clone $GIT_REPO $TMP_GIT_CLONE
> cd $TMP_GIT_CLONE
> bundle install
> time rake generate
> cp -Rf public/* $PUBLIC_WWW
> rm -Rf $TMP_GIT_CLONE
> exit
> EOF
server$ chmod +x hooks/post-receive
Clone repository on laptop
1
2
3
4
5
laptop$ git clone ssh://quartergeek@209.141.57.185/home/quartergeek/oi.abcdabcd987.com.git
laptop$ cd oi.abcdabcd987.com
laptop$ vim _config.yml
laptop$ vim source/_posts/2013-05-18-deploy-octopress-git-on-vps.markdown
laptop$ git push

Comments