以前に高機能 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 をインストールします。
curl --silent --location https://rpm.nodesource.com/setup_6.x | bash - yum -y install nodejs
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
でインストールします。
yum -y install mongodb-org
MongoDB のインストールが完了したら起動&自動起動設定を実施しておきます。
systemctl start mongod systemctl enable mongod
Redis のインストール
EPEL から Redis をインストールします。
yum -y install epel-release yum -y install redis
Redis のインストールが完了したら起動&自動起動設定を実施しておきます。
systemctl start redis systemctl enable redis
Java のインストール
Crowi-Plus で全文検索機能を利用するには ElasticSearch を使います。 ElasticSearch を動作させる上で必要なので Java をインストールしておきます。
yum -y install java-1.8.0-openjdk
Elasticsearch のインストール
ElasticSearch をインストールします。 まず、GPG 鍵をインストールします。
rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch
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 をインストールします。
yum -y install elasticsearch
ElasticSearch を動作させる上で以下のプラグインも必要です。
elasticsearch-plugin
でインストールしておきます。
/usr/share/elasticsearch/bin/elasticsearch-plugin install analysis-kuromoji /usr/share/elasticsearch/bin/elasticsearch-plugin install analysis-icu
ElasticSearch のインストールが完了したら起動&自動起動設定を実施しておきます。
systemctl start elasticsearch systemctl enable elasticsearch
yarn のインストール
Crowi-Plus は JavaScript のパッケージ管理に yarn
を使っているようです。 yarn
をインストールします。
wget https://dl.yarnpkg.com/rpm/yarn.repo -O /etc/yum.repos.d/yarn.repo yum -y install yarn
Crowi-Plus のインストール
これで Crowi-Plus を動作させる環境が整いました。 いよいよ Crowi-Plus をインストールします。 今回は /opt/crowi-plus
ディレクトリにインストールします。
cd /opt git clone https://github.com/weseek/crowi-plus.git cd crowi-plus yarn
環境変数の定義
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
して設定ファイルを読み込み直しておきます。
systemctl daemon-reload
Crowi を起動する
最後に、Crowi を起動&自動起動設定します。
systemctl start crowi systemctl enable crowi
(/etc/sysconfig/crowi
でも定義していますが) デフォルトでは TCP/3000 で Listen します。 ブラウザで「http://xxx.xxx.xxx.xxx:3000
」にアクセスすると Crowi-Plus のログイン画面が表示されるはずです。