在CentOS 8上安裝CodiMD 2.2.0

CodiMD分新舊版(新版可直接插入圖片)
舊版在github
https://github.com/hackmdio/codimd
新版需另從網站下載壓縮檔
https://github.com/hackmdio/codimd/releases/tag/2.2.0
安裝相依套件
yum install curl git
安裝 nodejs & npm
yum install epel-release
yum install nodejs
clone hackmd git(舊版才需要)
cd /opt
git clone https://github.com/hackmdio/hackmd.git
安裝 CodiMD
舊版
cd /opt/hackmd
cp config.json.example config.json
bin/setup
新版
將 codimd-2.2.0.zip 解壓縮後,目錄改為codimd,上傳至 /opt 目錄。
cd /opt/codimd
cp config.json.example config.json
bin/setup
安裝 PostgreSQL 資料庫
yum install postgresql-server postgresql-contrib
postgresql-setup initdb
systemctl start postgresql
- 進入 PostgreSQL:
sudo -u postgres psql - 變更密碼:
\password //password - 查詢 Database:
\l> - 建立 CodiMD的Database:
CREATE DATABASE $codimdDB OWNER postgres; - 查詢 user:
\du - quit:
\q
pg_hba.conf 設定
cd /var/lib/pgsql/data
ls -l pg_hba*
cp pg_hba.conf pg_hba.conf.org
設定如下:
# PostgreSQL Client Authentication Configuration File"
# ==================================================="
local all all trust
host all all 127.0.0.1/32 trust
host all all ::1/128 trust
CodiMD PostgreSQL 連線
編輯初始化檔案 vi /opt/hackmd/.sequelizerc 或 /opt/codimd/.sequelizerc
module.exports = {
config: path.resolve('config.js'),
'migrations-path': path.resolve('lib', 'migrations'),
'models-path': path.resolve('lib', 'models'),
'url': 'postgres://postgres:password@localhost:5432/$codimdDB'
}
config.json 設定
-
設定config.json
{ "production": { "loglevel": "info", "db": { "username": "postgres", "password": "password", "database": "dbname", "host": "localhost", "port": "5432", "dialect": "postgres" }, "linkifyHeaderStyle": "gfm" } } -
啟動服務
cd /opt/codimd 或 /opt/hackmd npm run build node_modules/.bin/sequelize db:migrate export NODE_ENV=production npm start
設定防火牆
systemctl status firewalld
netstat -tlnp
firewall-cmd --zone=public --add-port=3000/tcp --permanent
firewall-cmd --reload
firewall-cmd --zone=public --list-all
啟動 CodiMD 服務
vi /etc/systemd/system/codimd.service
systemctl --system daemon-reload
systemctl enable codimd
systemctl start/stop/status codimd
設定上傳圖片目錄(新版才需要)

-
預設目錄 /opt/codimd/public/uploads
-
設定連結其它目錄
mkdir /uploads ln -s /uploads /opt/codimd/public/uploads
參考網址
https://spicyboyd.blogspot.com/2019/03/linux-hackmd-codimd.html
已知問題
- 以MySQL取代PostgreSQL沒有成功。
- 無使用者密碼變更功能。