wiki.js搭建自己的wiki wiki.js搭建 官网wiki.js: 目前这个wiki.js还存在一些bug,期待2.x版本正式发布!
软件依赖 wiki.js需要以下软件包:
git 2.7.4 or later is required
nodejs 6.11.1 or later is required.
mongodb 3.2 or later is required.
下面说以下这三个的安装方式 git安装 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 git --version weget https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.9.5.tar.gz tar -xzvf git-2.9.5.tar.gz cd git-2.9.5 make prefix=/usr/local/git all make prefix=/usr/local/git install whereis gitmv /usr/bin/git /usr/bin/git-2.15.gitmv /usr/local/bin/git /usr/local/bin/git-2.15.gitln -s /usr/bin/git /usr/local/git/bin/gitln -s /usr/local/git/bin/git /usr/bin/git git --version
mongodb安装 wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel62-4.0.0.tgz tar -xzvf mongodb-linux-x86_64-rhel62-4.0.0.tgzmv mongodb-linux-x86_64-rhel62-4.0.0 /usr/local/mongodbexport PATH=/usr/local/mongodb/bin:$PATH mkdir /data/mongodbmkdir /var/log/mongodb/ vim /etc/mongodb.conf
将以下配置写到mongodb.conf中 dbpath=/data/mongodb logpath=/var/log/mongodb/mongodb.log logappend=true bind_ip = 127.0.0.1 port = 27017 journal=true fork=true maxConns=50000 auth = false
启动mongodb: mongod --config /etc/mongodb.conf
安装nodejs curl --silent --location https://rpm.nodesource.com/setup_8.x | sudo bash - yum install gcc-c++ make yum install -y nodejs yarn
下载wiki.js mkdir /data/ wiki cd /data/ wiki wget https://gi thub.com/Requarks/ wiki/releases/ download/v1.0.78/ wiki-js.tar.gz wget https://gi thub.com/Requarks/ wiki/releases/ download/v1.0.78/ node_modules.tar.gz tar -xzvf wiki-js.tar.gz tar -xzvf node_modules.tar.gz cp -n config.sample.yml config.yml
配置wiki
配置mongodb权限 mongo >use wiki >db.createUser({user:'wiki' ,pwd :"123456" ,roles:[{role:"readWrite" ,db:"wiki" }]}) >exit ps -ef | grep mongo | grep -v grep | awk '{print $2}' | xargs kill mongod --config /etc/mongodb.conf db: 'mongodb://wiki:123456@localhost:27017/wiki'
重启wiki cd /data/wiki node wiki restart
nginx代理
我们启用nginx对wiki进行代理,wiki的域名暂为: wiki.example.com
在/usr/local/nginx/conf/vhost/下,创建文件wiki.conf,添加配置:server { listen 80; server_name wiki.example.com; location / { proxy_set_header Host $http_host ; proxy_set_header X-Real-IP $remote_addr ; proxy_pass http://127.0.0.1:8556; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade ; proxy_set_header Connection "upgrade" ; proxy_next_upstream error timeout http_502 http_503 http_504; } access_log /usr/local/nginx/logs/wiki.log; error_log /usr/local/nginx/logs/wiki.log; }
重启nginx: /usr/local/nginx/sbin/nginx -s reload
修改wiki源码 因wiki原代码在页面访问时对域名不友好,需修改wiki源代码:
config.yml配置 config.yml在node wiki configure进行配置后生成,可以通过修改这个文件并重启wiki来更改配置。当前配置模板:
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 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 title: wiki host: 'http://127.0.0.1‘ port: 8556 domain : ' http://wiki.example.com' paths: repo: ./repo data: ./data uploads: maxImageFileSize: 3 maxOtherFileSize: 100 lang: zh langRtl: false public: false auth: defaultReadAccess: false local: enabled: true google: enabled: true clientId: GOOGLE_CLIENT_ID clientSecret: GOOGLE_CLIENT_SECRET microsoft: enabled: true clientId: MS_APP_ID clientSecret: MS_APP_SECRET facebook: enabled: false clientId: FACEBOOK_APP_ID clientSecret: FACEBOOK_APP_SECRET github: enabled: false clientId: GITHUB_CLIENT_ID clientSecret: GITHUB_CLIENT_SECRET slack: enabled: false clientId: SLACK_CLIENT_ID clientSecret: SLACK_CLIENT_SECRET ldap: enabled: false url: ' ldap://serverhost:389' bindDn: cn=' root' bindCredentials: BIND_PASSWORD searchBase: ' o=users ,o=example.com' searchFilter: ' (uid={{username}})' tlsEnabled: false tlsCertPath: ' C:\example\root_ca_cert.crt' azure: enabled: false clientId: APP_ID clientSecret: APP_SECRET_KEY resource: 00000002-0000-0000-c000-000000000000 tenant: YOUR_TENANT.onmicrosoft.com oauth2: enabled: false clientId: OAUTH2_CLIENT_ID clientSecret: OAUTH2_CLIENT_SECRET authorizationURL: OAUTH2_AUTH_URL tokenURL: OAUTH2_TOKEN_URL sessionSecret: 89a845b448c498e23c4f46698255717bff6f718fd3e62c4f149494ee05da19cb db: ' mongodb://wiki:123456@localhost:27017/wiki' git: url: ' http://gitlab.example.com/dev/wiki.git' branch: master auth: type: basic username: wiki password: 123456@example.com privateKey: /etc/wiki/keys/git.pem sslVerify: true showUserEmail: true serverEmail: linxw@example.com features: linebreaks: true mathjax: true externalLogging: bugsnag: false loggly: false papertrail: false rollbar: false sentry: false theme: primary: indigo alt: blue-grey viewSource: all footer: blue-grey code: dark: true colorize: true
mongodb init.d 启停 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 #!/bin/sh EXE_FILE=/usr/local/mongodb/bin/mongod CONFIG_FILE=/etc/mongodb.conf MONGOPID=`ps -ef| grep mongodb.conf| grep -v grep| awk '{print $2}' `test -x $EXE_FILE || exit 0case "$1 " in start) echo "Starting MongoDB server" $EXE_FILE --config $CONFIG_FILE echo "mongoDB started" ;; stop) echo "Stopping MongoDB server" if [ ! -z "$MONGOPID " ]; then kill -15 $MONGOPID fi echo "MongoDB stopped" ;; status) ps -ef| grep mongodb.conf | grep -v grep ;; restart) echo "Stopping MongoDB server" if [ ! -z "$MONGOPID " ]; then kill -15 $MONGOPID fi echo "Starting MongoDB server" $EXE_FILE --config $CONFIG_FILE echo "MongoDB restarted" ;; *) echo "Usage: /etc/init.d/mongodb {start|stop|status}" exit 1esac exit 0