如何在Ubuntu 18.04 LTS上安装Gollum Wiki
本教程将在Ubuntu 18.04 LTS上解释Gollum Wiki。
Gollum是一个开源简单的Wiki系统,内置于Git之上。
Wiki内容存储在Git存储库中作为文本文件,可以组织到目录中。
Gollum与所有识别的文件格式一起工作,包括图像,PDF和标题/页脚。
Gollum页面可以用各种标记语言编写,可以从内置的Web界面,文本编辑器或者IDE编辑。
还支持宏等高级功能,如宏,UML图,元数据等。
在Ubuntu 18.04上安装Gollum Wiki
本节将讨论在Ubuntu 18.04上安装Gollum Wiki的步骤。
我们将首先安装所需的依赖项,然后在Ubuntu 18.04上构建和配置Gollum Wiki。
第1步:安装Gollum&Repencevies
我们需要安装所有依赖项。
运行以下命令以安装它们。
sudo apt update sudo apt install -y ruby ruby-dev make zlib1g-dev libicu-dev build-essential git asciidoc cmake
在Ruby中写的Gollum和许多红宝石的宝石都是必需的。
让我们确保安装基本。
sudo gem install gollum \ org-ruby \ omnigollum \ github-markup \ omniauth-github
所有Gollum标记都是由Github-Markup Gem呈现的,但我们可以通过额外的安装轻松添加对其他标记的支持。
例子:
Mediawiki:
sudo gem install wikicloth
纺织品:
sudo gem install RedCloth
GitHub味道爆炸:
sudo gem install github-markdown
第2步:设置Gollum Git存储库
在初始安装之后,Gollum需要指向GIT存储库进行工作。
让我们首先添加专用用户来访问该存储库。
$sudo adduser --shell /bin/bash --gecos 'Gollum application' gollum Adding user gollum' ... Adding new groupgollum' (1001) … Adding new user gollum' (1001) with groupgollum' … Creating home directory /home/gollum' ... Copying files from/etc/skel' … Enter new UNIX password: <Enter Password> Retype new UNIX password: <Retype Password> passwd: password updated successfully
切换到Gollum用户并配置Git用户名和电子邮件地址。
sudo su - gollum git config --global user.name "John Doe" git config --global user.email "Hyman@theitroad"
创建Wiki目录并初始化它。
$mkdir wiki && cd wiki $git init . Initialized empty Git repository in /home/gollum/wiki/.git/
第3步:配置Gollum Systemd服务
当服务器启动时,我们将在将Gollum启动作为SystemD服务。
这将使我们能够控制它 start/stop/restart
当我们需要关闭它时(例如升级)。
创建Gollum配置目录
sudo mkdir /etc/gollum/
Add configuration template.
$cat<<EOF | sudo tee /etc/gollum/config.rb =begin This file can be used to (e.g.): - alter certain inner parts of Gollum, - extend it with your stuff. It is especially useful for customizing supported formats/markups. For more information and examples: - https://github.com/gollum/gollum#config-file =end # enter your Ruby code here ... EOF
创建一个新的gollum systemd单元文件。
$cat<<EOF | sudo tee /etc/systemd/system/gollum.service [Unit] Description=Gollum wiki server After=network.target After=syslog.target [Service] Type=simple User=gollum Group=gollum WorkingDirectory=/home/gollum/wiki/ ExecStart=/usr/local/bin/gollum --live-preview --config "/etc/gollum/config.rb" Restart=on-abort [Install] WantedBy=multi-user.target EOF
重新加载系统配置
sudo systemctl daemon-reload
启动并使服务启动启动。
sudo systemctl start gollum.service sudo systemctl enable gollum.service
检查服务状态,应该显示 running
。
$systemctl status gollum gollum.service - Gollum wiki server Loaded: loaded (/etc/systemd/system/gollum.service; enabled; vendor preset: enabled) Active: active (running) since Sat 2019-03-16 10:08:45 PDT; 9s ago Main PID: 4527 (gollum) Tasks: 2 (limit: 1110) CGroup: /system.slice/gollum.service `-4527 /usr/bin/ruby2.5 /usr/local/bin/gollum --live-preview --config /etc/gollum/config.rb Mar 16 10:08:45 ubuntu-01 systemd[1]: Started Gollum wiki server. Mar 16 10:08:46 ubuntu-01 gollum[4527]: [2019-03-16 10:08:46] INFO WEBrick 1.4.2 Mar 16 10:08:46 ubuntu-01 gollum[4527]: [2019-03-16 10:08:46] INFO ruby 2.5.1 (2016-03-29) [x86_64-linux-gnu] Mar 16 10:08:46 ubuntu-01 gollum[4527]: == Sinatra (v1.4.8) has taken the stage on 4567 for development with backup from WEBrick Mar 16 10:08:46 ubuntu-01 gollum[4527]: [2019-03-16 10:08:46] INFO WEBrick::HTTPServer#start: pid=4527 port=4567
Gollum在TCP端口上运行
$ss -tunelp | grep 4567 tcp LISTEN 0 128 0.0.0.0:4567 0.0.0.0:* users:(("gollum",pid=4527,fd=7)) uid:1001 ino:63478 sk:5 <->
网络仪表板可以访问服务器IP地址和端口4567.
第4步:配置nginx代理
默认设置是在服务器IP地址上公开Gollum Web控制台。
如果要通过域名访问它,则需要配置nginx。
在Ubuntu 18.04上安装nginx web服务器
sudo apt -y install nginx
安装后,添加nginx配置。
sudo vim /etc/nginx/conf.d/gollum.conf
修改以下数据并将其添加到文件中。
server { listen 80; server_name wiki.example.com www.wiki.example.com; location/{ proxy_pass http://127.0.0.1:4567; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_connect_timeout 150; proxy_send_timeout 100; proxy_read_timeout 100; proxy_buffers 4 32k; client_max_body_size 500m; client_body_buffer_size 128k; } access_log /var/log/nginx/gollum-access.log; error_log /var/log/nginx/gollum-error.log; }
代替 wiki.example.com
使用域名并验证nginx配置。
$sudo nginx -t nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful
重新启动nginx以加载新的配置文件。
sudo systemctl restart nginx
对于SSL配置。
请参阅下面的配置文件。
server { listen 443 ssl http2; server_name wiki.example.com www.wiki.example.com; location/{ proxy_pass http://127.0.0.1:4567; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_connect_timeout 150; proxy_send_timeout 100; proxy_read_timeout 100; proxy_buffers 4 32k; client_max_body_size 500m; client_body_buffer_size 128k; } ssl on; ssl_certificate /etc/letsencrypt/live/wiki.example.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/wiki.example.com/privkey.pem; ssl_session_timeout 5m; ssl_ciphers EECDH+CHACHA20:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5; ssl_protocols TLSv1.2; ssl_prefer_server_ciphers on; access_log /var/log/nginx/gollum-access.log; error_log /var/log/nginx/gollum-error.log; } server { listen 80; server_name wiki.example.com; add_header Strict-Transport-Security max-age=2592000; rewrite ^ https://$server_name$request_uri? permanent; }
其中:wiki.example.com是wiki/etc/letsencrypt/live/wiki.example.com/pullchain.pem的域名是SSL证书的路径./etc/letsencrypt/live/wiki.example.com/privkey.pem是SSL私钥的路径。
上面的ConfigurationN将重定向所有HTTP流量到HTTPS。