[wiki--gitit]在Linux系统搭建gitit wiki

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/suxiang198/article/details/77921072

简述

对于喜欢用markdown写博客或做一些笔记,或者做学习知识库整理……等等之类的,gitit wiki是不错的wiki系统选择。因为一般的markdown语法是很简单的,以至于太简单而许多需要使用稍微复杂些的图表之类的,就不能太好的支持,因此是比较影响书写的。因此对于markdown就出现了许多的Extended的版本,这其中有个Pandoc的,使用支持pandoc扩展语法的markdown写wiki,那么wiki原始.md文件,可以通过强大的Pandoc工具,可以在书籍格式、PDF格式、word格式、epub格式、html格式……等等之间进行自动的生成,甚至可以生成PPT slide。
而gitit wiki系统,就可以显示这些支持pandoc extension的markdown语法的.md文件进行显示,有各种链接、图表展示等功能,很适合打造自己的私人wiki系统。
接下来介绍如何在Linux系统(可以是自己的Linux Server)上部署gitit wiki,之后自己可以使用自己的PC电脑进行登陆和wiki的维护与更新,只要联网,随时随地访问和更新。

Haskell开发工具安装

Why Haskell? 因为gitit是使用Haskell开发的,gitit的源码在github,因此Linux的方式是,将source code clone过来,然后安装Haskell开发工具,然后对gitit的源码进行编译和安装,这样就达到了安装gitit的目的。

stack(首选,最可靠)

stack就是Haskell的开发工具,“Stack is a cross-platform program for developing Haskell projects.”跨平台。关于stack的说明以及安装,可参考The Haskell Tool Stack
我在自己的64 bit的Debian系统,使用如下命令安装stack:

curl -sSL https://get.haskellstack.org/ | sh
# 或如下命令(Debian使用curl可以成功,Ubuntu下使用wget才成功,所以这两个可以根据情况试一试)
wget -qO- https://get.haskellstack.org/ | sh

不过一开始并不能成功安装,shell给出了如下的log:

Detected Linux distribution: debian

Installing dependencies...

sudo: unable to resolve host my_host_name
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package libffi-dev
E: Unable to locate package libgmp-dev
E: Unable to locate package zlib1g-dev
Installing apt packages failed.  Please run 'apt-get update' and try again.

于是按照提示输入:

apt-get update

果然更新了不少东西,然后再次输入上面的“curl -sSL https://get.haskellstack.org/ | sh”,此时就能安装成功了:

root@my_host_name:~# curl -sSL https://get.haskellstack.org/ | sh
Detected Linux distribution: debian

Installing dependencies...

sudo: unable to resolve host my_host_name
Reading package lists... Done
Building dependency tree
Reading state information... Done
g++ is already the newest version.
g++ set to manually installed.
gcc is already the newest version.
libc6-dev is already the newest version.
libc6-dev set to manually installed.
make is already the newest version.
make set to manually installed.
xz-utils is already the newest version.
The following extra packages will be installed:
  libgmpxx4ldbl
Suggested packages:
  libgmp10-doc libmpfr-dev
The following NEW packages will be installed:
  libffi-dev libgmp-dev libgmpxx4ldbl zlib1g-dev
0 upgraded, 4 newly installed, 0 to remove and 5 not upgraded.
Need to get 1,006 kB of archives.
After this operation, 2,778 kB of additional disk space will be used.
Get:1 http://mirrors.cloud.aliyuncs.com/debian/ jessie/main libgmpxx4ldbl amd64 2:6.0.0+dfsg-6 [22.1 kB]
Get:2 http://mirrors.cloud.aliyuncs.com/debian/ jessie/main libffi-dev amd64 3.1-2+deb8u1 [157 kB]
Get:3 http://mirrors.cloud.aliyuncs.com/debian/ jessie/main libgmp-dev amd64 2:6.0.0+dfsg-6 [621 kB]
Get:4 http://mirrors.cloud.aliyuncs.com/debian/ jessie/main zlib1g-dev amd64 1:1.2.8.dfsg-2+b1 [206 kB]
Fetched 1,006 kB in 0s (2,417 kB/s)
Selecting previously unselected package libgmpxx4ldbl:amd64.
(Reading database ... 39920 files and directories currently installed.)
Preparing to unpack .../libgmpxx4ldbl_2%3a6.0.0+dfsg-6_amd64.deb ...
Unpacking libgmpxx4ldbl:amd64 (2:6.0.0+dfsg-6) ...
Selecting previously unselected package libffi-dev:amd64.
Preparing to unpack .../libffi-dev_3.1-2+deb8u1_amd64.deb ...
Unpacking libffi-dev:amd64 (3.1-2+deb8u1) ...
Selecting previously unselected package libgmp-dev:amd64.
Preparing to unpack .../libgmp-dev_2%3a6.0.0+dfsg-6_amd64.deb ...
Unpacking libgmp-dev:amd64 (2:6.0.0+dfsg-6) ...
Selecting previously unselected package zlib1g-dev:amd64.
Preparing to unpack .../zlib1g-dev_1%3a1.2.8.dfsg-2+b1_amd64.deb ...
Unpacking zlib1g-dev:amd64 (1:1.2.8.dfsg-2+b1) ...
Processing triggers for man-db (2.7.0.2-5) ...
Processing triggers for install-info (5.2.0.dfsg.1-6) ...
Setting up libgmpxx4ldbl:amd64 (2:6.0.0+dfsg-6) ...
Setting up libffi-dev:amd64 (3.1-2+deb8u1) ...
Setting up libgmp-dev:amd64 (2:6.0.0+dfsg-6) ...
Setting up zlib1g-dev:amd64 (1:1.2.8.dfsg-2+b1) ...
Processing triggers for libc-bin (2.19-18+deb8u10) ...

Using generic bindist...

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:--  0:00:02 --:--:--     0
100   628    0   628    0     0    180      0 --:--:--  0:00:03 --:--:--  1956
100 11.4M  100 11.4M    0     0   984k      0  0:00:11  0:00:11 --:--:-- 2397k
Installing Stack to: /usr/local/bin/stack...

-------------------------------------------------------------------------------

Stack has been installed to: /usr/local/bin/stack

WARNING: '/root/.local/bin' is not on your PATH.
    For best results, please add it to the beginning of PATH in your profile.

这里看到了上面的WARNING提示,于是使用下面的命令将’/root/.local/bin’加入到环境变量PATH中:

PATH=$PATH:/root/.local/bin
#通过“echo $PATH”可以查看是否已经加入PATH中

在上面步骤完成后,最好还使用下面的命令更新下stack,以便避免系统更新带来的问题:

stack upgrade

Haskell Platform(仅作备选介绍,Debian下实测未成功)

如果不想使用stack,Debian中可以安装Haskell Platform,不过试了下,后续安装等待了很久都没有动静:

sudo apt-get install haskell-platform

gitit编译与安装

如果使用stack工具

首先安装git工具–“apt-get install git”,然后运行如下命令,分别是clone gitit源代码,在stack中编译与安装gitit:

git clone https://github.com/jgm/gitit
cd gitit
stack install

不过在Debian上使用stack install时,从log看貌似有些东西要从亚马孙awx镜像中去下载,好几次出现了connection timeout,不过尝试了多次,并中途用了stack setup后,stack install终于可以开始运作了,不过整个编译过程相对是比较缓慢的。
在该过程结束后,貌似gitit没有成功安装,因为gitit命令提示找不到……
没办法,后面换用Ubuntu系统再尝试,在使用stack install命令后,等了一个下午,之后发现仍然卡在:

Updating package index Hackage (mirrored at https://s3.amazonaws.com/hackage.fpcomplete.com/) ...

这里没动,没办法,停止后再次使用stack install尝试,然后终于开始看到mirror连接到了,开始Progress中了。

如果使用Haskell Platform(备用,Debian下用了下未能成功)

使用如下的命令:

cabal update
cabal install gitit

使用cabal update命令后,会看到先找/root/.cabal/config,没有找到就会创建默认的,然后再去hackage.haskell.org下载最新的package。
不过使用haskell platform, 使用cabal install安装clone下来的本地的gitit时一直出现问题:

Resolving dependencies...
cabal: Could not resolve dependencies:
trying: gitit-0.12.2.1 (user goal)
next goal: base (dependency of gitit-0.12.2.1)
rejecting: base-4.6.0.1/installed-96b... (conflict: gitit => base>=4.9 && <5)
rejecting: base-4.10.0.0, 4.9.1.0, 4.9.0.0, 4.8.2.0, 4.8.1.0, 4.8.0.0,
4.7.0.2, 4.7.0.1, 4.7.0.0, 4.6.0.1, 4.6.0.0, 4.5.1.0, 4.5.0.0, 4.4.1.0,
4.4.0.0, 4.3.1.0, 4.3.0.0, 4.2.0.2, 4.2.0.1, 4.2.0.0, 4.1.0.0, 4.0.0.0,
3.0.3.2, 3.0.3.1 (global constraint requires installed instance)
Dependency tree exhaustively searched.

而使用“cabal install gitit”安装时,也是类似的提示base不符合。
这里不清楚什么原因,可能是gitit版本更新到了0.12.2造成了系统中dependencies的兼容问题了。

猜你喜欢

转载自blog.csdn.net/suxiang198/article/details/77921072