0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

続・UbuntuにCodiMDをManual Deploymentするときのメモ

Last updated at Posted at 2025-10-06

こちらの記事の続きになります
UbuntuにCodiMDをManual Deploymentするときのメモ

前回、最新のCodiMD2.6.1でビルドエラーが出たため2.5.4を使っておりましたが、2.6.1のエラー回避方法がわかりましたのでメモとして残しておきます。

環境

Ubuntu 24.04.3 LTS

導入手順

nodejsとnpmのインストール

cd ~
sudo apt install vim git libssl-dev -y
sudo apt install nodejs -y
sudo apt install npm -y
#ここでnodeのバージョンが取得できないことがあるのでPCを再起動する
sudo reboot

PostgreSQLにDBを作成

sudo apt install postgresql -y
sudo -u postgres psql
create role hackmd with login password 'hackmdpass';
create database hackmd owner hackmd encoding 'UTF8';
\q

最新のCodiMD2.6.1を導入

cd ~
sudo mkdir work
cd work
git clone https://github.com/hackmdio/codimd.git -b 2.6.1 --depth 1 
cd codimd
bin/setup

config.jsonファイルを編集

sudo vim config.json
:warning:development 部分を編集する

{
    "test": {
        "db": {
            "dialect": "sqlite",
            "storage": ":memory:"
        },
        "linkifyHeaderStyle": "gfm"
    },
    "development": {
        "loglevel": "info",
        "hsts": {
            "enable": false
        },
        "db": {
    	    "username": "hackmd",
    	    "password": "hackmdpass",
    	    "database": "hackmd",
    	    "host": "localhost",
    	    "port": "5432",
            "dialect": "postgres"
        },
        "linkifyHeaderStyle": "gfm",
    	"defaultPermission": "freely",
    	"allowAnonymous": true,
    	"allowFreeURL": false,
    	"allowPDFExport": true,
    	"email": true,
    	"allowEmailRegister": true
    },
    "production": {
        "domain": "localhost",
        "loglevel": "info",
        "hsts": {
            "enable": true,
            "maxAgeSeconds": 31536000,
            "includeSubdomains": true,
            "preload": true
        },
        "csp": {
            "enable": true,
            "directives": {
            },
            "upgradeInsecureRequests": "auto",
            "addDefaults": true,
            "addDisqus": true,
            "addGoogleAnalytics": true
        },
        "db": {
            "username": "",
            "password": "",
            "database": "codimd",
            "host": "localhost",
            "port": "5432",
            "dialect": "postgres"
        },
        "facebook": {
            "clientID": "change this",
            "clientSecret": "change this"
        },
        "twitter": {
            "consumerKey": "change this",
            "consumerSecret": "change this"
        },
        "github": {
            "clientID": "change this",
            "clientSecret": "change this",
            "organizations": ["names of github organizations allowed, optional"],
            "scopes": ["defaults to 'read:user' scope for auth user"]
        },
        "gitlab": {
            "baseURL": "change this",
            "clientID": "change this",
            "clientSecret": "change this",
            "scope": "use 'read_user' scope for auth user only or remove this property if you need gitlab snippet import/export support (will result to be default scope 'api')",
            "version": "use 'v4' if gitlab version > 11, 'v3' otherwise. Default to 'v4'"
        },
        "mattermost": {
            "baseURL": "change this",
            "clientID": "change this",
            "clientSecret": "change this"
        },
        "dropbox": {
            "clientID": "change this",
            "clientSecret": "change this",
            "appKey": "change this"
        },
        "google": {
            "clientID": "change this",
            "clientSecret": "change this",
            "apiKey": "change this"
        },
        "ldap": {
            "url": "ldap://change_this",
            "bindDn": null,
            "bindCredentials": null,
            "searchBase": "change this",
            "searchFilter": "change this",
            "searchAttributes": ["change this"],
            "usernameField": "change this e.g. cn",
            "useridField": "change this e.g. uid",
            "tlsOptions": {
                "changeme": "See https://nodejs.org/api/tls.html#tls_tls_connect_options_callback"
            }
        },
        "saml": {
            "idpSsoUrl": "change: authentication endpoint of IdP",
            "idpCert": "change: certificate file path of IdP in PEM format",
            "issuer": "change or delete: identity of the service provider (default: serverurl)",
            "identifierFormat": "change or delete: name identifier format (default: 'urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress')",
            "disableRequestedAuthnContext": "change or delete: true to allow any authentication method, false restricts to password authentication method (default: false)",
            "groupAttribute": "change or delete: attribute name for group list (ex: memberOf)",
            "requiredGroups": [ "change or delete: group names that allowed" ],
            "externalGroups": [ "change or delete: group names that not allowed" ],
            "attribute": {
               "id": "change or delete this: attribute map for `id` (default: NameID)",
               "username": "change or delete this: attribute map for `username` (default: NameID)",
               "email": "change or delete this: attribute map for `email` (default: NameID)"
            }
        },
        "imgur": {
            "clientID": "change this"
        },
        "minio": {
          "accessKey": "change this",
          "secretKey": "change this",
          "endPoint": "change this",
          "secure": true,
          "port": 9000
        },
        "s3": {
          "accessKeyId": "change this",
          "secretAccessKey": "change this",
          "region": "change this"
        },
        "s3bucket": "change this",
        "azure":
        {
          "connectionString": "change this",
          "container": "change this"
        },
        "plantuml":
        {
          "server": "https://www.plantuml.com/plantuml"
        },
        "linkifyHeaderStyle": "gfm"
    }
}

.sequelizercを編集

const path = require('path')
const config = require('./lib/config')

module.exports = {
  config: path.resolve('config.js'),
  'migrations-path': path.resolve('lib', 'migrations'),
  'models-path': path.resolve('lib', 'models'),
  url: 'postgres://hackmd:hackmdpass@localhost:5432/hackmd'
}

CodiMDをビルド + 起動

node_modules/.bin/sequelize db:migrate
npm run build
#ここで Error: error:0308010C:digital envelope routines::unsupported というエラーが出ると思われます。
#以下のコマンドを実行して
export NODE_OPTIONS=--openssl-legacy-provider
#もう一度ビルドします
npm run build
#今度は問題なくビルドが実行できると思われます。
NODE_ENV='development'
node app.js

CodiMDの起動を確認する

ブラウザで http://localhost:3000 にアクセスする
https___qiita-image-store.s3.ap-northeast-1.amazonaws.com_0_139073_2b3795cb-eea5-471d-b65d-d7faa23edf88.avif

最新のCodiMD2.6.1をManual Deploymentするときのコツ

#↓のコマンドを実行して Error: error:0308010C:digital envelope routines::unsupported エラーを回避する!
export NODE_OPTIONS=--openssl-legacy-provider
  • node 18.19.1
  • npm 9.2.0
  • CodiMD 2.6.1

参考にさせていただいたサイト

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?