Quick Start
通过git hooks快速将blog push到vps, 懒人必备。
Prepare vps
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| addusr git
gpasswd -a git sudo
usermod -aG wheel git
ssh-copy-id -i ~/.ssh/id_rsa.pub git@ip(xxx.xxx.xxx.xxx)
sudo apt-get install git-core nginx
|
1 2 3 4 5 6 7 8 9 10
| mkdir /home/git/wiki.git cd /home/git/wiki.git/ git init --bare
mkdir /var/www/wiki
chown git:git -R /var/www/wiki
|
1 2 3 4 5 6 7 8 9 10 11 12
| cd /home/git/wiki.git/hooks vim post-receive
#!/bin/bash GIT_REPO=/home/git/wiki.git TMP_GIT_CLONE=/tmp/wiki PUBLIC_WWW=/var/www/wiki rm -rf ${TMP_GIT_CLONE} git clone $GIT_REPO $TMP_GIT_CLONE rm -rf ${PUBLIC_WWW}/* cp -rf ${TMP_GIT_CLONE}/* ${PUBLIC_WWW}
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| vi /etc/nginx/conf.d/wiki.conf server { listen 80 ; root /var/www/wiki; server_name wiki.itabas.com; access_log /var/log/nginx/wiki_access.log; error_log /var/log/nginx/wiki_error.log; location ~* ^.+\.(ico|gif|jpg|jpeg|png)$ { root /var/www/wiki; access_log off; expires 1d; } location ~* ^.+\.(css|js|txt|xml|swf|wav)$ { root /var/www/wiki; access_log off; expires 10m; } location / { root /var/www/wiki; if (-f $request_filename) { rewrite ^/(.*)$ /$1 break; } } }
|
Restart service
Configure blog yml
无论你使用哪个静态博客框架, 基本上都支持一键部署, 详细参数参照_config.yml