Markdown記法で書くことができる和製のOSS Wiki『Crowi』がなんかすごい良い感じに見えたので、CentOS 7にインストールしてみました。
ノウハウ共有ツールとしてQiita:Teamやesaなどのクラウドサービスを社内規定などで利用できない環境の人には便利かなと。
目次
インストールするソフト
Crowiの他にもDBなどインストールするものがあります。とりあえず本手順では下記をインストールします。
- Node.js (ver6系)
- MongoDB
- Redis
- Elasticsearch(全文検索エンジン)
- Java (Elasticsearchで必要)
- Crowi
Node.js (ver6系) のインストール
# curl -sL https://rpm.nodesource.com/setup_6.x | bash - && yum -y install nodejs # node -v v6.12.1
MongoDBをインストール
# vim /etc/yum.repos.d/mongodb.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 # systemctl start mongod # systemctl status mongod # systemctl enable mongod # systemctl is-enabled mongod
Redisをインストール
# yum install epel-release # yum install redis # systemctl start redis # systemctl status redis # systemctl enable redis # systemctl is-enabled redis
Javaのインストール (Elasticsearchで必要になる)
# yum install java
Elasticsearch(全文検索エンジン)のインストール
# vim /etc/yum.repos.d/elasticsearch.repo
下記を記載。
[elasticsearch-5.x] name=Elasticsearch repository for 5.x packages
baseurl=https://artifacts.elastic.co/packages/5.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=1
autorefresh=1
type=rpm-md
# yum install elasticsearch # systemctl start elasticsearch # systemctl status elasticsearch # systemctl enable elasticsearch # systemctl is-enabled elasticsearch
kuromojiプラグインをインストールして日本語検索へ対応する。
# cd /usr/share/elasticsearch/bin # ./elasticsearch-plugin install analysis-kuromoji # systemctl restart elasticsearch # systemctl status elasticsearch # curl localhost:9200
Crowiをインストール
# yum install git gcc-c++ krb5-devel # useradd crowi # su - crowi $ git clone https://github.com/crowi/crowi.git $ cd crowi $ git checkout $(git tag | tail -n 1) $ npm install
下記エラーが表示されるけどそのままでOK。
npm WARN prefer global jshint@2.9.5 should be installed with -g
npm WARN prefer global node-gyp@3.6.2 should be installed with -g
$ echo 'use crowi' | mongo $ mongo crowi --eval 'db.createUser({user: "crowi", pwd: "karipassword", roles: [{role: "readWrite", db: "crowi"}]})' $ mongo admin --eval "db.system.users.find()" $ exit # vim /etc/systemd/system/crowi.service
下記を記載。
[Unit] Description=Crowi
After=network.target mongod.service[Service] WorkingDirectory=/home/crowi/crowi
EnvironmentFile=/etc/sysconfig/crowi
ExecStart=/usr/bin/node app.js[Install] WantedBy=multi-user.target
# vim /etc/sysconfig/crowi
下記を記載。
PORT=3000
NODE_ENV=production
MONGO_URI=”mongodb://crowi:karipassword@localhost/crowi”
REDIS_URL=”redis://localhost:6379″
ELASTICSEARCH_URI=”http://localhost:9200″
PASSWORD_SEED=”【ランダム英数字記号の64文字】”
FILE_UPLOAD=local
crowiを起動。
# systemctl status crowi # systemctl start crowi # systemctl status crowi # systemctl enable crowi # systemctl is-enabled crowi
crowiにアクセスして動作を確認する。
http://[サーバのIPアドレス]:3000/
これでCrowiがCentOS 7にインストールされたはずです。