OlitGlobal
Linux
tags: Common 目標
- 建立可以搭配 LDAP 的 wiki
- LDAP:Lightweight Directory Access Protocol 輕型目錄存取協定
Source Code
Tutorial 教學
步驟1:安裝套件
-
sudo apt-get install curl git npm node-gyp gcc
-
安裝 nodejs
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash - sudo apt-get install -y nodejs -
安裝 yarn
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add - echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list sudo apt-get update && sudo apt-get install yarn sudo apt-get update && sudo apt-get install --no-install-recommends yarn
步驟2:clone CodiMD git
cd /opt
git clone https://github.com/hackmdio/codimd.git
步驟3:安裝 CodiMD
- 建立設定檔:
cp config.json.example config.json
- 開始安裝 CodiMD:
bin/setup
步驟4:安裝 Database
MySQL
-
sudo apt-get install mysql-server
-
進入 MySQL:
mysql -u root -p
-
查詢 Database:
show databases;
-
建立 CodiMD的Database:
CREATE DATABASE codimd CHARACTER SET utf8 COLLATE utf8_general_ci;
-
查詢 host, user:
select host,user from mysql.user;
-
quit:
\q
PostgreSQL
sudo apt-get install postgresql-client
sudo apt-get install postgresql
- 啟動 PostgreSQL:
sudo service postgresql start
- 進入 PostgreSQL:
sudo -u postgres psql
- 查詢 Database:
\l
- 建立 CodiMD的Database:
CREATE DATABASE exampledb OWNER dbuser;
- 查詢 user:
\du
- quit:
\q
步驟5:設定 Database 連線
vim /opt/codimd/.sequelizerc
- 修改 url
- MySQL:
mysql://USERNAME:PASSWORD@localhost:3306/DBNAME
- PostgreSQL:
postgres://username:password@localhost:5432/codimd
- MySQL:
步驟6:設定 config.json 重點
vim /opt/codimd/config.json
- 官方文件
"email": false,
"allowanonymous": false,
- db
- MySQL"db": { "username": "root", "password": "1234", "database": "codimd", "host": "localhost", "port": "3306", "dialect": "mysql" }
- PostgreSQL"db": { "username": "root", "password": "1234", "database": "codimd", "host": "localhost", "port": "5432", "dialect": "postgres" }
- MySQL
- ldap
"ldap": {
"url": "ldap://IP",
"bindDn": "",
"bindCredentials": "",
"searchBase": "",
"searchFilter": "(&(objectcategory=person)(objectclass=user)(|(samaccountname={{username}})(mail={{username}})))",
"searchAttribute": ""
}
步驟7:啟動服務
cd /opt/codimd
npm run build
node_modules/.bin/sequelize db:migrate
步驟8:服務器啟用
npm start
- 開啟瀏覽器:
localhost:3000
Result 結果畫面
-
不能匿名創建、編輯文件
-
只能透過 LDAP 登入
-
登入後,畫面
沒有留言:
張貼留言