CentOS7 に Markdown で書ける Wiki「Crowi-Plus」をインストールする
以前に高機能 Wiki「Crowi」を Docker で手軽に試すというメモを書きましたが、Crowi は Markdown で書ける Wiki です。 この Crowi を更に拡張したのが Crowi-Plus です。 今回は CentOS7 に Crowi-Plus をインストールする手順をメモしておきます。
依存関係¶
現時点で Crowi-Plus は以下のソフトウェアに依存しているそうです。 順次、インストールしていきます。
- node 6.x (DON'T USE 7.x)
- npm 4.x (DON'T USE 5.x)
- yarn
- MongoDB 3.x
Node.js 6.x 系のインストール¶
Node.js をインストールします。
MongoDB のインストール¶
MongoDB をインストールします。 MongoDB の公式リポジトリを追加します。
cat << "_EOF_" > /etc/yum.repos.d/mongodb.repo
[mongodb-org-3.6]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.6/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-3.6.asc
_EOF_
追加したリポジトリから yum でインストールします。
MongoDB のインストールが完了したら起動&自動起動設定を実施しておきます。
Redis のインストール¶
EPEL から Redis をインストールします。
Redis のインストールが完了したら起動&自動起動設定を実施しておきます。
Java のインストール¶
Crowi-Plus で全文検索機能を利用するには ElasticSearch を使います。 ElasticSearch を動作させる上で必要なので Java をインストールしておきます。
Elasticsearch のインストール¶
ElasticSearch をインストールします。 まず、GPG 鍵をインストールします。
ElasticSearch の公式リポジトリを追加します。
cat << "_EOF_" > /etc/yum.repos.d/elasticsearch.repo
[elasticsearch-6.x]
name=Elasticsearch repository for 6.x packages
baseurl=https://artifacts.elastic.co/packages/6.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=1
autorefresh=1
type=rpm-md
_EOF_
追加したリポジトリから yum で ElasticSearch をインストールします。
ElasticSearch を動作させる上で以下のプラグインも必要です。
elasticsearch-plugin でインストールしておきます。
/usr/share/elasticsearch/bin/elasticsearch-plugin install analysis-kuromoji
/usr/share/elasticsearch/bin/elasticsearch-plugin install analysis-icu
ElasticSearch のインストールが完了したら起動&自動起動設定を実施しておきます。
yarn のインストール¶
Crowi-Plus は JavaScript のパッケージ管理に yarn を使っているようです。 yarn をインストールします。
Crowi-Plus のインストール¶
これで Crowi-Plus を動作させる環境が整いました。 いよいよ Crowi-Plus をインストールします。 今回は /opt/crowi-plus ディレクトリにインストールします。
環境変数の定義¶
Crowi-Plus が起動時に参照する環境変数を /etc/sysconfig/crowi に定義しておきます。
cat << _EOF_ > /etc/sysconfig/crowi
PORT=3000
NODE_ENV=production
MONGO_URI="mongodb://localhost:27017/crowi"
REDIS_URL="redis://localhost:6379"
ELASTICSEARCH_URI="http://localhost:9200"
#SECRET_TOKEN=
PASSWORD_SEED="`openssl rand -base64 128 | head -1`"
FILE_UPLOAD=local
_EOF_
自動起動スクリプト¶
今回は CentOS7 上に Crowi-Plus をインストールしている為、systemd 用の設定ファイルを用意しておきます。
cat << "_EOF_" > /etc/systemd/system/crowi.service
[Unit]
Description=Crowi
After=network.target mongod.service
[Service]
WorkingDirectory=/opt/crowi-plus
EnvironmentFile=/etc/sysconfig/crowi
ExecStart=/usr/bin/npm start
[Install]
WantedBy=multi-user.target
_EOF_
systemd の設定ファイルを追加した為、daemon-reload して設定ファイルを読み込み直しておきます。
Crowi を起動する¶
最後に、Crowi を起動&自動起動設定します。
(/etc/sysconfig/crowi でも定義していますが) デフォルトでは TCP/3000 で Listen します。 ブラウザで「http://xxx.xxx.xxx.xxx:3000」にアクセスすると Crowi-Plus のログイン画面が表示されるはずです。