CentOS7.4にオンプレで使えるwikiのGROWiをインストールしてみた

CentOS7.4にオンプレで使えるwikiのGROWiをインストールしてみました。フリーで使えるので、社内で情報共有したい場合に便利です。CentOSに導入すれば、基本的に費用をかけずに社内wikiをオンプレで構築することができます。CentOS7.4にオンプレで使えるwikiのGROWiをインストールしてみました。フリーで使えるので、社内で情報共有したい場合に便利です。CentOSに導入すれば、基本的に費用をかけずに社内wikiをオンプレで構築することができます。

 

これまでwikiに近い物では、redmineを構築したことがありますが、色んなOSSを使っていくことで、費用をかけずにシステムを利用できるようになります。

 

まずは、GROWIの公式サイトです。
https://growi.org/

 

続いて、機能の一部抜粋です。


Markdown左右2画面でのリアルタイムプレビューが可能。言語ごとのコードハイライトや絵文字や注釈(footnotes)、タスクリストにも対応しています。

●シンプルなアセット管理ファイルのアップロードは編集画面にファイルをドロップするだけです。ストレージはローカルFSと AWS S3 のどちらかを選択できます

●高速な全文検索ElasticSearch を利用したページ検索が可能です。日本語ユーザーにもやさしく、英数字は全角半角どちらでもヒットするようになっています。

●強力な認証機構・グループ管理Passportによる認証機構を採用、LDAP 認証をサポートしています。(各種 OAuth 認証には、近々対応予定です)また、v3.0 からはグループごとのアクセスコントロールを搭載し、より柔軟なページ管理が可能になりました。

 

今回は初めてのインストールなので、とりあえずログ残しということで、別途、手順を整理して、分かりやすいものに修正します。

 

こちらのwikiクラウド、docker、オンプレで構築できますが、今回はオンプレの手順を参考にしました。
https://github.com/weseek/growi#on-premise

 

【依存関係】

・node 8.x (DON'T USE 9.x)・npm 5.x・yarn・MongoDB 3.x

【依存関係オプション】

・Redis 3.x・ElasticSearch 5.x (needed when using Full-text search)

 

また、インストールにはこちらのブログを参考にさせてもらいました。
AWS 上の CentOS7 に Growi をインストールする

 

事前準備

・ネットワークの設定(割愛)

ファイアウォールの無効化(割愛)

SELinuxの無効化(割愛)

 

Node.js 8.x 系のインストール
まずは、Node.js 8.xのインストールです。ちなみに、公式サイトによると、9.xは使用しないほうがいいそうです。

 

-------------

[root@TestServer ~]# curl --silent --location https://rpm.nodesource.com/setup_8.x | bash -
## Installing the NodeSource Node.js 8.x repo...

## Inspecting system...
+ rpm -q --whatprovides redhat-release || rpm -q --whatprovides centos-release || rpm -q --whatprovides cloudlinux-release || rpm -q --whatprovides sl-release+ uname -m
## Confirming "el7-x86_64" is supported...
+ curl -sLf -o /dev/null 'https://rpm.nodesource.com/pub_8.x/el/7/x86_64/nodesource-release-el7-1.noarch.rpm'
## Downloading release setup RPM...
+ mktemp+ curl -sL -o '/tmp/tmp.pZr1M0hZzV' 'https://rpm.nodesource.com/pub_8.x/el/7/x86_64/nodesource-release-el7-1.noarch.rpm'
## Installing release setup RPM...
+ rpm -i --nosignature --force '/tmp/tmp.pZr1M0hZzV'
## Cleaning up...
+ rm -f '/tmp/tmp.pZr1M0hZzV'
## Checking for existing installations...
+ rpm -qa 'node|npm' | grep -v nodesource
## Run `yum install -y nodejs` (as root) to install Node.js 8.x and npm.## You may also need development tools to build native addons:##   `yum install -y gcc-c++ make`-------------

「Run `yum install -y nodejs` (as root) to install Node.js 8.x and npm」というメッセージがあるので、以下を実行しました。
-------------

[root@TestServer ~]# yum -y install nodejs

読み込んだプラグイン:fastestmirror, langpacksnodesource                                                                                                                            | 2.5 kB  00:00:00     nodesource/x86_64/primary_db                                     0% [                                                      ]  0.0 B/s |    0 B  --:--:-- ETA nodesource/x86_64/primary_db                                                                                                          |  34 kB  00:00:00     Loading mirror speeds from cached hostfile * base: mirror.fairway.ne.jp * extras: www.ftp.ne.jp * updates: www.ftp.ne.jp依存性の解決をしています--> トランザクションの確認を実行しています。---> パッケージ nodejs.x86_64 2:8.11.1-1nodesource を インストール--> 依存性解決を終了しました。
依存性を解決しました
============================================================================================================================================================= Package                          アーキテクチャー                 バージョン                                     リポジトリー                          容量=============================================================================================================================================================インストール中: nodejs                           x86_64                           2:8.11.1-1nodesource                           nodesource                            17 M
トランザクションの要約=============================================================================================================================================================インストール  1 パッケージ
総ダウンロード容量: 17 Mインストール容量: 51 MDownloading packages:
~中略~  検証中                  : 2:nodejs-8.11.1-1nodesource.x86_64                                                                                           1/1 
インストール:  nodejs.x86_64 2:8.11.1-1nodesource                                                                                                                         
完了しました!

[root@TestServer ~]# 

-------------
続いてバージョン確認です。
-------------

[root@TestServer ~]# node -v

v8.11.1

[root@TestServer ~]# npm -v

5.6.0

-------------

MongoDB のインストール
続いて、MongoDBのインストールです。
Install MongoDB Community Edition on Red Hat Enterprise or CentOS Linux

まずはレポジトリファイルを作成します。
-------------

[root@TestServer ~]# vi /etc/yum.repos.d/mongodb-org-3.6.repo

以下の内容をコピーして、作成したファイルにペーストします。

[mongodb-org-3.6]name=MongoDB Repositorybaseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.6/x86_64/gpgcheck=1enabled=1gpgkey=https://www.mongodb.org/static/pgp/server-3.6.asc

[:wq!]で保存

-------------
MongoDBのインストール。
-------------

[root@TestServer ~]# yum install -y mongodb-org

読み込んだプラグイン:fastestmirror, langpacksmongodb-org-3.6                                                                                                                       | 2.5 kB  00:00:00mongodb-org-3.6/7/primary_db                                                                                                          |  27 kB  00:00:00Loading mirror speeds from cached hostfile * base: mirror.fairway.ne.jp * extras: www.ftp.ne.jp * updates: www.ftp.ne.jp依存性の解決をしています-org
~ 中略 ~
インストール:  mongodb-org.x86_64 0:3.6.4-1.el7
依存性関連をインストールしました:  mongodb-org-mongos.x86_64 0:3.6.4-1.el7             mongodb-org-server.x86_64 0:3.6.4-1.el7             mongodb-org-shell.x86_64 0:3.6.4-1.el7  mongodb-org-tools.x86_64 0:3.6.4-1.el7
完了しました!

-------------
MongoDBを起動してみる。※このまえに、selinuxを使う要件がなければ、事前にDisableにしておきます。手順は省略。
-------------

[root@TestServer ~]# systemctl start mongod

[root@TestServer growi]# systemctl status mongod

● mongod.service - High-performance, schema-free document-oriented database   Loaded: loaded (/usr/lib/systemd/system/mongod.service; enabled; vendor preset: disabled)   Active: active (running) since 土 2018-04-28 12:34:57 JST; 1min 37s ago     Docs: https://docs.mongodb.org/manual Main PID: 45890 (mongod)   CGroup: /system.slice/mongod.service           mq45890 /usr/bin/mongod -f /etc/mongod.conf
 4月 28 12:34:56 TestServer systemd[1]: Starting High-performance, schema-f.... 4月 28 12:34:56 TestServer mongod[45886]: about to fork child process, wai.... 4月 28 12:34:56 TestServer mongod[45886]: forked process: 45890 4月 28 12:34:57 TestServer systemd[1]: Started High-performance, schema-fr....Hint: Some lines were ellipsized, use -l to show in full.

-------------
自動起動設定
-------------

[root@TestServer ~]# systemctl enable mongod

[root@TestServer ~]#

[root@TestServer ~]# systemctl list-unit-files | grep mongodmongod.service                                enabled

[root@TestServer ~]#

-------------
DBへ接続してみる。バージョンも確認できますね。導入バージョンは「3.6.4」※抜けるときは、「ctrl+c」
-------------

[root@TestServer ~]# mongo --host 127.0.0.1:27017

MongoDB shell version v3.6.4connecting to: mongodb://127.0.0.1:27017/MongoDB server version: 3.6.4Welcome to the MongoDB shell.For interactive help, type "help".For more comprehensive documentation, see        http://docs.mongodb.org/Questions? Try the support group        http://groups.google.com/group/mongodb-userServer has startup warnings:2018-04-22T15:28:52.223+0900 I CONTROL  [initandlisten]2018-04-22T15:28:52.223+0900 I CONTROL  [initandlisten] ** WARNING: Access control is not enabled for the database.2018-04-22T15:28:52.223+0900 I CONTROL  [initandlisten] **          Read and write access to data and configuration is unrestricted.2018-04-22T15:28:52.223+0900 I CONTROL  [initandlisten]2018-04-22T15:28:52.223+0900 I CONTROL  [initandlisten]2018-04-22T15:28:52.223+0900 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.2018-04-22T15:28:52.223+0900 I CONTROL  [initandlisten] **        We suggest setting it to 'never'2018-04-22T15:28:52.223+0900 I CONTROL  [initandlisten]2018-04-22T15:28:52.223+0900 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.2018-04-22T15:28:52.223+0900 I CONTROL  [initandlisten] **        We suggest setting it to 'never'2018-04-22T15:28:52.223+0900 I CONTROL  [initandlisten]>

-------------
続いて、「redis」のインストールです。事前にインストールされるバージョンを確認し、epelからインストールを行います。

 


-------------

[root@TestServer ~]# yum list | grep redis

pcp-pmda-redis.x86_64                       3.11.8-7.el7               base
[root@TestServer ~]# yum -y install epel-release

yum -y install redis読み込んだプラグイン:fastestmirror, langpacks
~ 中略 ~
インストール:  epel-release.noarch 0:7-9
完了しました!

-------------

redisのインストール
「redis」のインストールです。
-------------

[root@TestServer ~]# yum -y install redis

読み込んだプラグイン:fastestmirror, langpacks
~ 中略 ~
インストール:  redis.x86_64 0:3.2.10-2.el7
依存性関連をインストールしました:  jemalloc.x86_64 0:3.6.0-1.el7
完了しました!

-------------
バージョン確認と、自動起動設定。
-------------

[root@TestServer ~]# redis-cli -vredis-cli 3.2.10
[root@TestServer ~]# systemctl start redis

[root@TestServer ~]# systemctl enable redis

Created symlink from /etc/systemd/system/multi-user.target.wants/redis.service to /usr/lib/systemd/system/redis.service.-------------
動作確認
-------------

[root@TestServer ~]# redis-cli ping

PONG

-------------

JAVAのインストール
JAVAの確認。すでにインストールされていたので、スキップ。ちなみに、要件はJava8以降で、Oralce JDKですが、このまま利用。

Elasticsearch requires at least Java 8. Specifically as of this writing, it is recommended that you use the Oracle JDK version 1.8.0_73.

-------------

[root@TestServer ~]# java -version

openjdk version "1.8.0_131"OpenJDK Runtime Environment (build 1.8.0_131-b12)OpenJDK 64-Bit Server VM (build 25.131-b12, mixed mode)

-------------

Elasticsearchのインストール
続いて、Elasticsearchのインストールです。
-------------

[root@TestServer ~]# vi /etc/yum.repos.d/elasticsearch.repo
以下の内容をコピー&ペースト。

 

[elasticsearch-5.x]name=Elasticsearch repository for 5.x packagesbaseurl=https://artifacts.elastic.co/packages/5.x/yumgpgcheck=1gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearchenabled=1autorefresh=1type=rpm-md

 

[wq!]で保存。

[root@TestServer ~]# yum -y install elasticsearch

読み込んだプラグイン:fastestmirror, langpackselasticsearch-5.x
~ 中略 ~
Downloading packages:警告: /var/cache/yum/x86_64/7/elasticsearch-5.x/packages/elasticsearch-5.6.9.rpm: ヘッダー V4 RSA/SHA512 Signature、鍵 ID d88e42b4: NOKEY32 MB  00:00:00 ETAelasticsearch-5.6.9.rpm の公開鍵がインストールされていませんelasticsearch-5.6.9.rpm                                                                                                               |  32 MB  00:00:22https://artifacts.elastic.co/GPG-KEY-elasticsearch から鍵を取得中です。Importing GPG key 0xD88E42B4: Userid     : "Elasticsearch (Elasticsearch Signing Key) <dev_ops@elasticsearch.org>" Fingerprint: 4609 5acc 8548 582c 1a26 99a9 d27d 666c d88e 42b4 From       : https://artifacts.elastic.co/GPG-KEY-elasticsearch
~ 中略 ~
  検証中                  : elasticsearch-5.6.9-1.noarch                                                                                                 1/1
インストール:  elasticsearch.noarch 0:5.6.9-1
完了しました!

[root@TestServer ~]#

-------------
依存関係オプションの以下の二つも合わせてインストールします。

・Redis 3.x

・ElasticSearch 5.x (needed when using Full-text search)
-------------[

root@TestServer ~]# /usr/share/elasticsearch/bin/elasticsearch-plugin install analysis-kuromoji

-> Downloading analysis-kuromoji from elastic[=================================================] 100%??-> Installed analysis-kuromoji

[root@TestServer ~]# /usr/share/elasticsearch/bin/elasticsearch-plugin install analysis-icu

-> Downloading analysis-icu from elastic[=================================================] 100%??-> Installed analysis-icu

[root@TestServer ~]#

-------------
続いてelasticsearchの自動起動設定です。
-------------

[root@TestServer ~]# systemctl start elasticsearch

[root@TestServer ~]# systemctl enable elasticsearch

Created symlink from /etc/systemd/system/multi-user.target.wants/elasticsearch.service to /usr/lib/systemd/system/elasticsearch.service.

[root@TestServer ~]# elasticsearch.service                         enabled

-------------

yarnのインストール
-------------

[root@TestServer ~]# wget https://dl.yarnpkg.com/rpm/yarn.repo -O /etc/yum.repos.d/yarn.repo

[root@TestServer ~]# yum -y install yarn

-------------


GROWIのインストール
GROWIのインストールにgitを使うんですが、デフォルトでコマンドが通らなかったので、インストール。
[root@TestServer opt]# git clone https://github.com/weseek/TestServer.gitbash: git: コマンドが見つかりませんでした...

[root@TestServer opt]#
~中略~
インストール:  git.x86_64 0:1.8.3.1-12.el7_4
依存性関連をインストールしました:  perl-Error.noarch 1:0.17020-2.el7        perl-Git.noarch 0:1.8.3.1-12.el7_4  perl-TermReadKey.x86_64 0:2.30-20.el7
完了しました!

-------------
続けてgitのインストール。
-------------

[root@localhost opt]# yum -y install git

読み込んだプラグイン:fastestmirror, langpacksLoading mirror speeds from cached hostfileインストール:  git.x86_64 0:1.8.3.1-12.el7_4
依存性関連をインストールしました:  perl-Error.noarch 1:0.17020-2.el7        perl-Git.noarch 0:1.8.3.1-12.el7_4  perl-TermReadKey.x86_64 0:2.30-20.el7
完了しました!

-------------
続けてGROWIのインストール。
-------------

[root@TestServer ~]# cd /opt/

[root@TestServer opt]# git clone https://github.com/weseek/growi.git

Cloning into 'growi'...remote: Counting objects: 22079, done.remote: Compressing objects: 100% (163/163), done.remote: Total 22079 (delta 112), reused 135 (delta 67), pack-reused 21849Receiving objects: 100% (22079/22079), 7.04 MiB | 1.47 MiB/s, done.Resolving deltas: 100% (15846/15846), done.[root@TestServer opt]# cd growi[root@TestServer growi]# yarnyarn install v1.6.0[1/5] Validating package.json...[2/5] Resolving packages...[3/5] Fetching packages...info fsevents@1.1.3: The platform "linux" is incompatible with this module.info "fsevents@1.1.3" is an optional dependency and failed compatibility check. Excluding it from installation.[4/5] Linking dependencies...[5/5] Building fresh packages...Done in 89.04s.[root@TestServer growi]#[root@TestServer growi]# MONGO_URI=mongodb://localhost:27017/growi npm start

-------------
環境変数の定義です。
-------------

vi /etc/sysconfig/growi
以下の内容をコピー&ペースト。

PORT=3000NODE_ENV=productionMONGO_URI="mongodb://localhost:27017/growi"REDIS_URL="redis://localhost:6379"ELASTICSEARCH_URI="http://localhost:9200"#SECRET_TOKEN=PASSWORD_SEED="`openssl rand -base64 128 | head -1`"FILE_UPLOAD=local

 

[wq!]で保存。
-------------
続いて自動起動の設定です。
-------------

[root@TestServer growi]# vi /etc/systemd/system/growi.service
[Unit]Description=GrowiAfter=network.target mongod.service
[Service]WorkingDirectory=/opt/growiEnvironmentFile=/etc/sysconfig/growiExecStart=/usr/bin/npm start
[Install]WantedBy=multi-user.target

上記をコピー&ペーストし、[wq!]で上書き保存します。設定ファイルを読み込み直し。
[root@TestServer growi]# systemctl daemon-reload

-------------
そして、起動起動設定を行います。
-------------

[root@TestServer growi]# systemctl start growi

[root@TestServer growi]# systemctl enable growiCreated symlink from /etc/systemd/system/multi-user.target.wants/growi.service to /etc/systemd/system/growi.service.

[root@TestServer growi]# systemctl list-unit-files | grep growigrowi.service                                 enabled

[root@TestServer growi]#

-------------

この手順でそのままGROWIのURLにアクセスすると画面が表示されないので、一旦、サーバを再起動。以下のURLからアクセスし、以下の画面が表示されればOKです。

f:id:merrywhite:20200711081146j:plain

 

後、管理画面は表示されるようになりましたが、「MONGO_URI=mongodb://MONGO_HOST:MONGO_PORT/growi npm start」実行時の以下のメッセージがきになりますかね。別途調査したいと思います。

 crowi:crowi DB Connect Error:  Error: Slash in host identifier    at parseConnectionString (/opt/growi/node_modules/mongodb/lib/url_parser.js:202:15)

 

最初のアカウントを作成するとログインでき、そのアカウントは管理権限が付与されます。

f:id:merrywhite:20200711081203j:plain



 

次は、新機能のLADP認証を確認してみたいと思います。後、手順をもう少し分かりやすく整理したいと思います。