mindoc 文档管理系统搭建

写在前面的话

每篇一句

行百里者半九十

你是否有N个内网系统,各种环境:生产、灾备、测试,系统越来越多,你只能靠你的小本本记录,同事也是常互相询问所管理的系统访问地址。作为运维的你,开发的一些自动化脚本,你想同事在你休假的时候明白其调用方法。你总结的文章想共享在内部系统。那么你可以尝试下mindoc这个工具。

MinDoc 简介

下面这段介绍来源于搭建好mindoc 创建的普通文档模版

MinDoc 是一款针对IT团队开发的简单好用的文档管理系统。

MinDoc 的前身是 SmartWiki 文档系统。SmartWiki 是基于 PHP 框架 laravel 开发的一款文档管理系统。因 PHP 的部署对普通用户来说太复杂,所以改用 Golang 开发。可以方便用户部署和实用。

开发缘起是公司IT部门需要一款简单实用的项目接口文档管理和分享的系统。其功能和界面源于 kancloud 。

可以用来储存日常接口文档,数据库字典,手册说明等文档。内置项目管理,用户管理,权限管理等功能,能够满足大部分中小团队的文档管理需求。

演示站点: http://doc.iminho.me

安装与使用

安装环境介绍及版本

glibc库要求大于等于2.14版本,Centos7默认自带满足,Centos6需要手动升级,有风险。

  • Centos 7

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    [root@master data]# uname -a
    Linux master 3.10.0-514.el7.x86_64 #1 SMP Tue Nov 22 16:42:41 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
    [root@master data]# cat /etc/redhat-release
    CentOS Linux release 7.3.1611 (Core)
    [root@master mindoc]# rpm -qa |grep glibc
    glibc-headers-2.17-157.el7.x86_64
    compat-glibc-headers-2.12-4.el7.centos.x86_64
    glibc-2.17-157.el7.x86_64
    glibc-common-2.17-157.el7.x86_64
    glibc-devel-2.17-157.el7.x86_64
    compat-glibc-2.12-4.el7.centos.x86_64
  • mysql 社区版5.7

    1
    2
    [root@master ~]# mysql -V
    mysql Ver 14.14 Distrib 5.7.19, for Linux (x86_64) using EditLine wrapper

安装前准备

Centos 国内yum 源配置

加快软件安装速度,国内有网易163阿里清华等大学免费镜像站,下面以163为例。

1
2
3
4
5
cd /etc/yum.repos.d/
mv CentOS-Base.repo CentOS-Base.repo.backup
wget http://mirrors.163.com/.help/CentOS7-Base-163.repo
yum clean all
yum makecache

go 安装

mindoc 是由go 语音编写的

1
2
3
cd /data/
wget https://storage.googleapis.com/golang/go1.9.1.linux-amd64.tar.gz
tar -C /usr/local -xzf go1.9.1.linux-amd64.tar.gz

/etc/profile 文件增加go环境变量配置

1
export PATH=$PATH:/usr/local/go/bin

使环境变量配置立即生效

1
source /etc/profile

验证go环境变量

1
2
[root@master ~]# go version
go version go1.9.1 linux/amd64

mysql 安装

mysql下载网址

1
2
3
wget --no-check-certificate https://repo.mysql.com/mysql57-community-release-el7-11.noarch.rpm
rpm -ivh mysql57-community-release-el7-11.noarch.rpm
yum install mysql-community-server

mysql 配置

增加默认字符集配置,防止出现乱码

1
2
3
4
5
6
7
8
9
10
[root@master ~]# cat /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
symbolic-links=0
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
character_set_server= utf8
[client]
default-character-set= utf8

mysql 服务开启及确认开机自动启动

1
2
3
4
systemctl start mysqld
systemctl enable mysqld
[root@master ~]# systemctl list-unit-files |grep -i mysqld
mysqld.service enabled

mysql 初始密码

1
2
3
4
5
6
7
8
[root@master ~]# cat /var/log/mysqld.log
2017-10-16T06:59:09.365112Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2017-10-16T06:59:10.596156Z 0 [Warning] InnoDB: New log files created, LSN=45790
2017-10-16T06:59:10.718918Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2017-10-16T06:59:10.778181Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 82f3affd-b23f-11e7-8a42-000c29530ed1.
2017-10-16T06:59:10.779299Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2017-10-16T06:59:10.780256Z 1 [Note] A temporary password is generated for root@localhost: G#(;vXBdp4il
2017-10-16T06:59:14.047069Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).

用初始化密码(G#(;vXBdp4il)登录数据库,修改默认密码复杂要求策略及建用户

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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
[root@master yum.repos.d]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.7.19
mysql> CREATE USER 'mindoc'@'localhost' IDENTIFIED BY '123456';
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
mysql> SHOW VARIABLES LIKE 'validate_password%';
+--------------------------------------+--------+
| Variable_name | Value |
+--------------------------------------+--------+
| validate_password_check_user_name | OFF |
| validate_password_dictionary_file | |
| validate_password_length | 8 |
| validate_password_mixed_case_count | 1 |
| validate_password_number_count | 1 |
| validate_password_policy | MEDIUM |
| validate_password_special_char_count | 1 |
+--------------------------------------+--------+
7 rows in set (0.03 sec)
mysql> set global validate_password_policy=0;
Query OK, 0 rows affected (0.06 sec)
mysql> set global validate_password_mixed_case_count=0;
Query OK, 0 rows affected (0.00 sec)
mysql> set global validate_password_number_count=3;
Query OK, 0 rows affected (0.00 sec)
mysql> set global validate_password_special_char_count=0;
Query OK, 0 rows affected (0.00 sec)
mysql> set global validate_password_length=3;
Query OK, 0 rows affected (0.00 sec)
mysql> CREATE USER 'mindoc'@'localhost' IDENTIFIED BY '123456';
Query OK, 0 rows affected (0.09 sec)
mysql> SHOW VARIABLES LIKE 'validate_password%';
+--------------------------------------+-------+
| Variable_name | Value |
+--------------------------------------+-------+
| validate_password_check_user_name | OFF |
| validate_password_dictionary_file | |
| validate_password_length | 3 |
| validate_password_mixed_case_count | 0 |
| validate_password_number_count | 3 |
| validate_password_policy | LOW |
| validate_password_special_char_count | 0 |
+--------------------------------------+-------+
7 rows in set (0.01 sec)
set password for 'root'@'localhost' =password('password');
CREATE USER 'mindoc'@'localhost' IDENTIFIED BY '123456';

创建mindoc需要使用的数据库,并赋权限给mindoc用户本地可以访问及控制该库mindoc_db

1
2
3
4
5
mysql> create database mindoc_db;
Query OK, 1 row affected (0.01 sec)
mysql> grant all privileges on mindoc_db.* to mindoc@localhost ;
Query OK, 0 rows affected (0.03 sec)

字符集确认

1
2
3
4
5
6
7
8
9
10
11
12
13
mysql> show variables like '%character%';
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+

mindoc 安装

mindoc v0.6版本介质下载
介质下载后上传及解压

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
mkdir /data/mindoc
cd /data/mindoc
tar -xzvf mindoc_linux_amd64.tar.gz
[root@master mindoc]# ls -l
总用量 27436
drwxr--r-- 2 root root 6 10月 20 11:24 cache
drwxrwxrwx 2 root root 46 10月 16 15:44 conf
-rwxrwxrwx 1 root root 2462 7月 10 19:29 favicon.ico
drwxrwxrwx 3 root root 18 7月 10 19:29 lib
drwxr-xr-x 5 root root 33 10月 20 11:24 logs
-rwxrwxrwx 1 root root 16718312 7月 10 19:32 mindoc_linux_amd64
-rw-r--r-- 1 root root 11327240 10月 16 15:23 mindoc_linux_amd64.tar.gz
-rw-r--r-- 1 root root 38020 10月 20 11:24 nohup.out
drwxrwxrwx 23 root root 333 7月 10 19:29 static
drwxrwxrwx 2 root root 258 7月 10 19:36 uploads
drwxrwxrwx 13 root root 182 7月 10 19:29 views

修改配置文件数据库配置部分,其他根据自身情况进行修改。

1
2
3
4
5
6
7
8
9
10
[root@master mindoc]# cp conf/app.conf.example conf/app.conf
[root@master mindoc]# cat conf/app.conf
####################MySQL 数据库配置###########################
#支持MySQL和sqlite3两种数据库,如果是sqlite3 则 db_database 标识数据库的物理目录
db_adapter=mysql
db_host=127.0.0.1
db_port=3306
db_database=mindoc_db
db_username=mindoc
db_password=123456

执行数据库初始化脚本

1
2
cd /data/mindoc
./mindoc_linux_amd64 install

mindoc 启动运行及登录验证

1
2
cd /data/mindoc
nohup ./mindoc_linux_amd64 >nohup.out 2>&1 &

注意linux防火墙需要打开8181端口,打开浏览器直接访问,默认用户名是admin,密码:123456
关闭防火墙

1
2
3
4
5
6
7
[root@master mindoc]# systemctl stop firewalld.service
[root@master mindoc]# systemctl status firewalld.service
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
Active: inactive (dead)
Docs: man:firewalld(1)
[root@master mindoc]# systemctl disable firewalld.service

mindoc 做成服务开机自动启动

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
cd /data/mindoc
./mindoc_linux_amd64 service install
[root@master mindoc]# systemctl start mindocd
[root@master mindoc]# systemctl enable mindocd
[root@master mindoc]# systemctl status mindocd
● mindocd.service - A document online management program.
Loaded: loaded (/etc/systemd/system/mindocd.service; enabled; vendor preset: disabled)
Active: active (running) since 五 2017-10-20 17:04:40 CST; 21s ago
Main PID: 18681 (mindoc_linux_am)
CGroup: /system.slice/mindocd.service
└─18681 /data/mindoc/mindoc_linux_amd64
10月 20 17:04:40 master systemd[1]: Started A document online management program..
10月 20 17:04:40 master systemd[1]: Starting A document online management program....
10月 20 17:04:40 master mindoc_linux_amd64[18681]: MinDoc version => v0.6
10月 20 17:04:40 master mindoc_linux_amd64[18681]: build time => Mon Jul 10 19:29:03 CST 2017
10月 20 17:04:40 master mindoc_linux_amd64[18681]: start directory => /data/mindoc/mindoc_linux_amd64
10月 20 17:04:40 master mindoc_linux_amd64[18681]: 2017/10/20 17:04:40 [I] [asm_amd64.s:2197] http server Running on http://:8181

mindoc pdf 导出功能配置

导出 pdf 格式文档使用的是wkhtmltopdf

下载对应稳定版本

1
2
3
4
5
wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.4/wkhtmltox-0.12.4_linux-generic-amd64.tar.xz
xz -d wkhtmltox-0.12.4_linux-generic-amd64.tar.xz
cp wkhtmltox-0.12.4_linux-generic-amd64.tar /data/
tar -xvf wkhtmltox-0.12.4_linux-generic-amd64.tar
cd /data/wkhtmltox/

依赖包安装

1
2
3
4
5
6
yum install zlib
yum install fontconfig
yum install freetype
yum install libX11
yum install libXext
yum install libXrender

验证生成pdf是否正常

可以访问外网,就拿百度做测试。无法访问外网,就随便拿个内网可以访问的url。

1
2
3
# cd /data/wkhtmltox/bin/
./wkhtmltopdf www.baidu.com test.pdf
./wkhtmltopdf http://x.x.x.x/docs/mindoc/1 test.pdf

下载test.pdf 用pdf软件打开查看是否正常

pdf中文乱码解决

1
2
3
4
mkdir -p /usr/share/fonts/chinese/TrueType/
ls -lrt
总用量 14988
-rw-r--r-- 1 root root 15323200 10月 17 09:54 simsun.ttc

再将windows C:\Windows\Fonts下宋体传到该目录
重新验证测试,乱码解决。

配置mindoc pdf导出设置

1
2
3
4
5
6
cd /data/mindoc/
cat conf/app.conf
###############配置PDF生成工具地址###################
wkhtmltopdf=/data/wkhtmltox/bin/wkhtmltopdf
systemctl restart mindocd

打开浏览器项目导出pdf,验证正常。

效果图展示

mindoc编辑效果图

浏览器访问,左边编辑,右边及时预览就可以实时看到效果。编写语言按照markdown语法
mindoc编辑效果图

pdf导出效果

htmltopdf导出效果图

其他问题可参考 mindoc 官方手册

----纸上得来终觉浅绝知此事要躬行----
最好的赞赏是您的阅读!
0%