安装Gollum

  • 安装Ruby
1
$ aptitude install ruby ruby-dev rubygems
  • 安装相关依赖
1
$ aptitude install libicu-dev
  • 安装Gollum
1
$ gem install gollum
  • 安装Markdown支持
1
2
$ gem install redcarpet
$ gem install github-markdown
  • 安装代码高亮
1
$ pip install Pygments
  • 创建Git仓库或者Clone一个仓库
1
2
3
4
5
$ mkdir wiki
$ cd wiki
$ git init
$ gollum
# 访问http://localhost:4567

配置Apache2

  • 启用Apache2的Proxy功能
1
2
$ a2enmod proxy
$ a2enmod proxy_http
  • 配置apache
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
$ vi /etc/apache2/mods-available/proxy.conf
ProxyRequests On
<Proxy *>
AddDefaultCharset off
Order deny,allow
#Deny from all
Allow from .shixf.com
</Proxy>

$ vi /etc/apache2/sites-available/default
ProxyRequests Off
ProxyPreserveHost On

<Proxy *>
Order deny,allow
Allow from all
</Proxy>

ProxyPass /wiki http://localhost:4567/wiki
ProxyPassReverse /wiki http://localhost:4567/wiki

<Location /wiki>
Order allow,deny
Allow from all
ProxyPass http://localhost:4567/wiki
ProxyPassReverse /wiki
</Location>
  • 启动Gollum(在Git库中提交custom.css与custom.js)
1
$ gollum --host localhost --no-edit --js --css --mathjax --gollum-path /var/www/knowledge/ --base-path wiki

设置Gollum自动化

  • 开机自动启动
1
2
3
4
5
6
7
8
9
10
11
$ echo PATH=$PATH
$ vi /var/www/wiki/.gollum.sh
#!/bin/bash

PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
export PATH

DIR="$( cd -P "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
gollum --host localhost --no-edit --js --css --mathjax --gollum-path $DIR --base-path wiki
$ vi /etc/rc.local
bash /var/www/wiki/.gollum.sh &
  • 自动更新Git(每小时更新一次)
1
2
3
4
5
6
7
8
9
10
11
$ echo PATH=$PATH
$ vi /var/www/wiki/.sync.sh
#!/bin/bash

PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
export PATH

DIR="$( cd -P "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
(cd $DIR && git pull && git push)
$ crontab -e
0 */1 * * * bash /var/www/wiki/.sync.sh