gollum: github上搭建个人wiki - Shuang0420/Shuang0420.github.io GitHub Wiki

博客凸显创作,维基则是整理的好工具,很多入门级别、复用别人的操作,如配置环境等,更适合发布在个人维基上,本文就以gollum+github搭建个人wiki做个示范。

开通Wiki

登陆Github,找到你所开通的Github项目的Settings栏目,开通Wikis,如果只希望别人可读不可写,勾选:Restrict edits to Collaborators only。如下图所示:

git clone下相应维基的git地址

 git clone [email protected]:Shuang0420/Shuang0420.github.io.wiki.git wiki

如果你之前没有设置git密钥,可以参照以下步骤先做配置,如果已经设置,请忽略。

  1. 查看是否已经有了ssh密钥:
cd ~/.ssh

如果没有密钥则不会有此文件夹,有则备份删除

  1. 生成密钥,得到两个文件:id_rsa 和 id_rsa.pub
ssh-keygen -t rsa -C “[email protected]
  1. 添加密钥到ssh:ssh-add id_rsa

  2. 在github上settings中添加ssh密钥,即“id_rsa.pub”里的公钥。

  3. 测试:ssh [email protected]

配置个人wiki

  1. 在wiki目录下,安装bundler
gem install bundler
  如果安装没有问题,可以跳过以下错误解决。
  <pre>
  ERROR:  Could not find a valid gem 'bundler' (>= 0), here is why:
            Unable to download data from https://rubygems.org/ - Errno::EPIPE: Broken pipe - SSL_connect (https://rubygems.org/latest_specs.4.8.gz)</pre>

  解决:
  <pre>gem source -a http://rubygems.org/
  gem install bundler</pre>

  然而还是有错误:
  <pre>Fetching: bundler-1.12.5.gem (100%)^[[A
  ERROR:  While executing gem ... (Gem::FilePermissionError)
      You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.</pre>

  因为没有sudo:
  <pre>sudo gem install bundler</pre>
  1. 新建Gemfile文件,内容如下:

       source "http://rubygems.org"
       gem 'redcarpet'
       gem "grit", '~> 2.5.0', git: 'https://github.com/gitlabhq/grit.git', ref: '42297cdcee16284d2e4eff23d41377f52fc28b9d'
       gem 'gollum', git: 'https://github.com/gollum/gollum.git'
  2. 运行:

       # 安装项目依赖的所有gem包;此命令会尝试更新系统中已存在的gem包
       bundle install

    时间有点久,耐心等待。 然而最后出现error,

    An error occurred while installing charlock_holmes (0.7.3), and Bundler cannot continue.
       Make sure that `gem install charlock_holmes -v '0.7.3'` succeeds before bundling.

    好。那就按要求安装。

    sudo gem install charlock_holmes -v '0.7.3'

    好。继续按要求安装。

    brew install icu4c

    再重来

    sudo gem install charlock_holmes -v '0.7.3'
    bundle install

    因为没有安装bundle

    gem install bundle

    安装后再次尝试运行

    bundle install

    error

    Could not reach host index.rubygems.org. Check your network connection and try again.

    出现这种错误可以尝试把Gemfile里的https改成http(互相转化进行尝试)

    bundle install

    终于成功!

  3. 已安装成功gollum等。然后运行:

    gollum

    走到这一步了本人还是遇到了万恶的失败。 看着已经安装好了

       Installing nokogiri 1.6.7.2 with native extensions
       Installing rack-protection 1.5.3
       Installing gollum-grit_adapter 1.0.1
       Installing sanitize 2.1.0
       Installing sinatra 1.4.7
       Installing gollum-lib 4.2.0
       Using gollum 4.0.1 from https://github.com/gollum/gollum.git (at master@5a5e56a)
       Bundle complete! 3 Gemfile dependencies, 24 gems now installed.
       Use `bundle show [gemname]` to see where a bundled gem is installed.
       

    然而实际并没有

       $ gollum
       -bash: gollum: command not found

    大写的忧伤。最后通过直接安装gollum解决。

    sudo gem install gollum
    gollum
  4. 终于可以在本地启动成功维基。打开网址:http://0.0.0.0:4567/,可以直接在浏览器中编辑。

    如果发现不能如下错误,请尝试更新ruby。

    更新ruby步骤 安装 RVM RVM:Ruby Version Manager,Ruby版本管理器,包括Ruby的版本管理和Gem库管理(gemset)

    curl -L get.rvm.io | bash -s stable
    source ~/.bashrc  
       source ~/.bash_profile 

    测试是否安装正常

    rvm -v  

    用RVM升级Ruby

       #查看当前ruby版本  
       ruby -v  
       #列出已知的ruby版本  
       rvm list known  
       #安装ruby 2.3.0
       rvm install 2.3.0 

    安装完成之后ruby -v查看是否安装成功。

    重新安装完毕后回到第3步。

github同步

在wiki目录下面,进行git库操作,提交本地对维基内容的修改。一切将自动保存在你的Github上的个人博客网站的wiki目录下面。

cd ~/wiki
git add .
git commit -am"first commit"
git push
⚠️ **GitHub.com Fallback** ⚠️