crowi-plusをCentOS6.9にインストールする

非常に使いやすそうで、いい感じのCrowiですが、派生版が出ているので使ってみます。

今回はApacheでいくつかvhostが動いているサーバにcrowi-plusを導入します。

オリジナル(Crowi)

http://site.crowi.wiki/

https://github.com/crowi/crowi

発展型(crowi-plus)

http://qiita.com/yuki-takei/items/5df9601039ccfc1df01f

https://github.com/weseek/crowi-plus

どちらも導入しましたが、オリジナルの方がビルドのハードルが高かったので
慣れていないならcrowi-plusをお勧めします。

crowi-plusを導入する準備

最低限動かすためにはnode.jsとmongodb、yarnがパッケージとして必要です。
また、npmがnode.jsに付随して(たぶん)必要です

まず必要に応じてパッケージのアップデート

# yum update

node.jsを入れます。

# curl --silent --location https://rpm.nodesource.com/setup_6.x | bash -

これを実行後、yum install nodejsを実行しても6.xが入らなかったので直接パッケージを指定します。

# rpm -ivh https://rpm.nodesource.com//pub_6.x/el/6/x86_64/nodejs-6.11.0-1nodesource.el6.x86_64.rpm

バージョンを確認します。

# node -v

npmを最新にしておきます。

# npm upgrade -g npm

バージョンを確認します。

# npm -v

mongoDBをインストールします。

# vi /etc/yum.repos.d/mongodb-org-3.4.repo
[mongodb-org-3.4]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.4/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-3.4.asc
# yum install mongodb-org

起動オプションを付けておきます。

# chkconfig mongod on

確認

# chkconfig

起動します。

# /etc/init.d/mongod start

念のためログを確認しておきます。

# tail -f /var/log/mongodb/mongod.log

yarnをインストールします。

# wget https://dl.yarnpkg.com/rpm/yarn.repo -O /etc/yum.repos.d/yarn.repo
# yum install yarn

crowi-plusのセットアップ

githubからcloneしてきます。

$ git clone https://github.com/weseek/crowi-plus.git

crowi-plusをcloneしたディレクトリに移動してセットアップします。

[xxxx@xxxxxxxxx crowi-plus]$ yarn

たったこれだけで準備が出来るなんて夢のようです。
※nodejsのバージョン不一致のエラーが発生することがあります。
その場合は想定されているバージョンに変更して上げる必要があります。
具体的には

# yum --showduplicate list nodejs

で該当のバージョンが存在しているか確認します。
適切なバージョンを指定してアップグレードorダウングレードします。

# yum upgrade nodejs-6.11.4

or

# yum downgrade nodejs-6.11.3

などです。

起動してみます。

$ MONGO_URI=mongodb://localhost/crowi npm start &

外部から3000番のポートにアクセスしてセットアップ出来れば一旦完了です。

自動起動

自動起動するように設定を加えていきます。

# npm install -g forever initd-forever log
[xxxx@xxxxxxxxx crowi-plus]$ initd-forever -n crowi-plus
[xxxx@xxxxxxxxx crowi-plus]$ chmod +x crowi-plus

ちょっと編集します。

$ vi crowi-plus
- nodeApp="/var/www/github/crowi-plus/"
+ nodeApp="/var/www/github/crowi-plus/app.js"

- $foreverApp start --pidFile $pidFile -l $logFile -a -d -c "$command" $nodeApp
+ FILE_UPLOAD=local MONGO_URI=mongodb://localhost/crowi $foreverApp start --pidFile $pidFile -l $logFile -a -d -c "$command" $nodeApp

起動スクリプトを移動します。

[xxxx@xxxxxxxxx crowi-plus]$ sudo mv crowi-plus /etc/init.d

サービスを登録します。

# chkconfig crowi-plus --add
# chkconfig crowi-plus on
# chkconfig
# /etc/init.d/crowi-plus start

VirtualHostへの追加

起動していることを確認したらapacheでvhostの設定を行っている箇所に

ProxyPass / http://wiki.xxxxx.xxxx:3000/
ProxyPassReverse / http://wiki.xxxxx.xxxx:3000/

を追加してあげます。
また、wiki.xxxxx.xxxxをhostsに追加するのも忘れないようにしましょう。

127.0.0.1 wiki.xxxxx.xxxx

こちらを参考にさせていただきました。
http://jimaoka.hatenablog.jp/entry/crowi-install

問題点

  • 一部のURLにポート指定の記載が残る
    • 貼り付けた画像URLとか
  • SMTPサーバの設定を追加してもメールが送信出来ない

メール送信に関しては環境の可能性も高いので引き続き調査します。

Check Also

RouterOSでのipipv6トンネルについて

フレッツ光クロスでMikroT …